Explorar el Código

More refactoring on pacman

Jguer hace 8 años
padre
commit
66c4a31b71
Se han modificado 1 ficheros con 13 adiciones y 14 borrados
  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
 		}
 	}