浏览代码

More refactoring on pacman

Jguer 8 年之前
父节点
当前提交
66c4a31b71
共有 1 个文件被更改,包括 13 次插入14 次删除
  1. 13 14
      pacman/pacman.go

+ 13 - 14
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
-	}
-	compL := func(len int, i int) bool {
-		return i > -1
-	}
-	finalL := func(i int) int {
-		return i - 1
-	}
-
-	// TopDown functions
-	if config.YayConf.SortMode == config.TopDown {
-		initL = func(len int) int {
+		if config.YayConf.SortMode == config.TopDown {
 			return 0
+		} else {
+			return len - 1
 		}
-		compL = func(len int, i int) bool {
+	}
+	compL := func(len int, i int) bool {
+		if config.YayConf.SortMode == config.TopDown {
 			return i < len
+		} else {
+			return i > -1
 		}
-		finalL = func(i int) int {
+	}
+	finalL := func(i int) int {
+		if config.YayConf.SortMode == config.TopDown {
 			return i + 1
+		} else {
+			return i - 1
 		}
 	}