diff options
| author | 2026-03-28 17:40:02 +0000 | |
|---|---|---|
| committer | 2026-03-28 17:40:02 +0000 | |
| commit | 06583274fa64ad6677773bf4ca54f69226388203 (patch) | |
| tree | 66354bf972d267bf7ee5135eb7e5b90c31f9fe4d /commitquery/context.go | |
| parent | format/commitgraph/read: Lifetime (diff) | |
| signature | No signature | |
commitquery: Make a reusable engine thingy
Diffstat (limited to 'commitquery/context.go')
| -rw-r--r-- | commitquery/context.go | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/commitquery/context.go b/commitquery/context.go index 3e9ceee8..92705182 100644 --- a/commitquery/context.go +++ b/commitquery/context.go @@ -7,9 +7,7 @@ import ( objectstore "codeberg.org/lindenii/furgit/object/store" ) -// Query owns the mutable node arena for commit-domain queries over one object -// store. -type Query struct { +type query struct { store objectstore.ReadingStore graph *commitgraphread.Reader @@ -22,13 +20,19 @@ type Query struct { touched []nodeIndex } -// New builds one reusable commit query arena over one object store and optional -// commit-graph reader. -func New(store objectstore.ReadingStore, graph *commitgraphread.Reader) *Query { - return &Query{ +func newQuery(store objectstore.ReadingStore, graph *commitgraphread.Reader) *query { + return &query{ store: store, graph: graph, byOID: make(map[objectid.ObjectID]nodeIndex), byGraphPos: make(map[commitgraphread.Position]nodeIndex), } } + +func (query *query) resetForReuse() { + for _, idx := range query.touched { + query.nodes[idx].marks = 0 + } + + query.touched = query.touched[:0] +} |
