]> git.giacomolli.uk - onechat/blobdiff - build_queue.go
Order functions by their first use
[onechat] / build_queue.go
index 540e396091f4023528d6d31edabcb61f438b8856..825277ce17f519472e60cb3928f63ad2194ead0e 100644 (file)
@@ -82,6 +82,18 @@ func (q *BuildQueue) Next() (NodeKey, bool) {
        return leaf, found
 }
 
        return leaf, found
 }
 
+// nextLeaf returns the oldest leaf in the window that can start.
+func (q *BuildQueue) nextLeaf() (NodeKey, bool) {
+       for _, id := range q.leaves[:min(len(q.leaves), buildLeafWindow)] {
+               key := NodeKey{0, id}
+               if !q.running[key] && !q.failed[key] {
+                       return key, true
+               }
+       }
+
+       return NodeKey{}, false
+}
+
 // Done removes a built node from the queue.
 func (q *BuildQueue) Done(key NodeKey) {
        delete(q.running, key)
 // Done removes a built node from the queue.
 func (q *BuildQueue) Done(key NodeKey) {
        delete(q.running, key)
@@ -126,18 +138,6 @@ func (q *BuildQueue) Running() int {
        return len(q.running)
 }
 
        return len(q.running)
 }
 
-// nextLeaf returns the oldest leaf in the window that can start.
-func (q *BuildQueue) nextLeaf() (NodeKey, bool) {
-       for _, id := range q.leaves[:min(len(q.leaves), buildLeafWindow)] {
-               key := NodeKey{0, id}
-               if !q.running[key] && !q.failed[key] {
-                       return key, true
-               }
-       }
-
-       return NodeKey{}, false
-}
-
 func (h BuildMergeHeap) Len() int {
        return len(h)
 }
 func (h BuildMergeHeap) Len() int {
        return len(h)
 }