Permalink
Browse files

refactor addPkgSorted. also, vercmp returns 255, not -1

  • Loading branch information...
falconindy committed Sep 11, 2010
1 parent d982573 commit 71970510c64e87a4382644ca75db005ea7b3bdfc
Showing with 6 additions and 10 deletions.
  1. +6 −10 gobble.go
View
@@ -37,21 +37,17 @@ var (
var pkgList = map[string]*list.List{}
func addPkgSorted(lst *list.List, pkg *archPkg) {
- p := lst.Front()
- ele := (p.Value).(*archPkg)
+ for p := lst.Front(); p != nil; p = p.Next() {
+ ele := (p.Value).(*archPkg)
- for {
- if vercmp(pkg.Version, ele.Version) == -1 {
+ /* vercmp returns -1, which underflows */
+ if vercmp(pkg.Version, ele.Version) == 255 {
lst.InsertBefore(pkg, p)
return
}
- if next := p.Next(); next == nil {
- lst.PushBack(pkg)
- return
- } else {
- p = p.Next()
- }
}
+
+ lst.PushBack(pkg)
}
func parsePkg(file string) *archPkg {

0 comments on commit 7197051

Please sign in to comment.