diff options
| author | 2026-03-29 13:38:19 +0000 | |
|---|---|---|
| committer | 2026-03-29 13:39:49 +0000 | |
| commit | 37707aada0157f255dbad920b917efb601184e12 (patch) | |
| tree | 29f79d242c764de8d6f1e65bcc847e53f21cd646 /commitquery/generation.go | |
| parent | commitquery: Context has been gone long ago (diff) | |
| signature | No signature | |
commitquery: Reorganize
Diffstat (limited to 'commitquery/generation.go')
| -rw-r--r-- | commitquery/generation.go | 43 |
1 files changed, 0 insertions, 43 deletions
diff --git a/commitquery/generation.go b/commitquery/generation.go deleted file mode 100644 index 935da104..00000000 --- a/commitquery/generation.go +++ /dev/null @@ -1,43 +0,0 @@ -package commitquery - -import ( - "math" - - objectid "codeberg.org/lindenii/furgit/object/id" -) - -// EffectiveGeneration returns one node's generation value. -func (query *query) effectiveGeneration(idx nodeIndex) uint64 { - if !query.nodes[idx].hasGeneration { - return generationInfinity - } - - return query.nodes[idx].generation -} - -const ( - generationInfinity = uint64(math.MaxUint64) -) - -func compareByGeneration(query *query) func(nodeIndex, nodeIndex) int { - return func(left, right nodeIndex) int { - leftGeneration := query.effectiveGeneration(left) - rightGeneration := query.effectiveGeneration(right) - - switch { - case leftGeneration < rightGeneration: - return -1 - case leftGeneration > rightGeneration: - return 1 - } - - switch { - case query.nodes[left].commitTime < query.nodes[right].commitTime: - return -1 - case query.nodes[left].commitTime > query.nodes[right].commitTime: - return 1 - } - - return objectid.Compare(query.nodes[left].id, query.nodes[right].id) - } -} |
