jobqueue: do not sort dependencies
While dependencies are purely internal, sorting and pruning them is a reasonable optimization. However, we wish to expose them in follow-up commits and then we want them to remain unchanged from the input. Nothing in the internal logic seems to rely on the fact the dependencies were sorted. Signed-off-by: Tom Gundersen <teg@jklm.no>
This commit is contained in:
parent
f355bdd426
commit
e72b14bdd1
3 changed files with 2 additions and 88 deletions
|
|
@ -17,7 +17,6 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"sort"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
|
|
@ -108,7 +107,7 @@ func (q *fsJobQueue) Enqueue(jobType string, args interface{}, dependencies []uu
|
|||
var j = job{
|
||||
Id: uuid.New(),
|
||||
Type: jobType,
|
||||
Dependencies: uniqueUUIDList(dependencies),
|
||||
Dependencies: dependencies,
|
||||
QueuedAt: time.Now(),
|
||||
}
|
||||
|
||||
|
|
@ -336,30 +335,6 @@ func (q *fsJobQueue) maybeEnqueue(j *job, updateDependants bool) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// Sorts and removes duplicates from `ids`.
|
||||
func uniqueUUIDList(ids []uuid.UUID) []uuid.UUID {
|
||||
s := map[uuid.UUID]bool{}
|
||||
for _, id := range ids {
|
||||
s[id] = true
|
||||
}
|
||||
|
||||
l := []uuid.UUID{}
|
||||
for id := range s {
|
||||
l = append(l, id)
|
||||
}
|
||||
|
||||
sort.Slice(l, func(i, j int) bool {
|
||||
for b := 0; b < 16; b++ {
|
||||
if l[i][b] < l[j][b] {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
})
|
||||
|
||||
return l
|
||||
}
|
||||
|
||||
// Select on a list of `chan uuid.UUID`s. Returns an error if one of the
|
||||
// channels is closed.
|
||||
//
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue