From 66c4a31b71b3ed72ccc094e76c47794cb81b3063 Mon Sep 17 00:00:00 2001 From: Jguer Date: Mon, 8 May 2017 18:19:58 +0100 Subject: [PATCH] More refactoring on pacman --- pacman/pacman.go | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/pacman/pacman.go b/pacman/pacman.go index 30643322..da32b714 100644 --- a/pacman/pacman.go +++ b/pacman/pacman.go @@ -21,25 +21,24 @@ func Search(pkgInputN []string) (s Query, n int, err error) { // BottomUp functions initL := func(len int) int { - return len - 1 + if config.YayConf.SortMode == config.TopDown { + return 0 + } else { + return len - 1 + } } compL := func(len int, i int) bool { - return i > -1 + if config.YayConf.SortMode == config.TopDown { + return i < len + } else { + return i > -1 + } } finalL := func(i int) int { - return i - 1 - } - - // TopDown functions - if config.YayConf.SortMode == config.TopDown { - initL = func(len int) int { - return 0 - } - compL = func(len int, i int) bool { - return i < len - } - finalL = func(i int) int { + if config.YayConf.SortMode == config.TopDown { return i + 1 + } else { + return i - 1 } }