From 06583274fa64ad6677773bf4ca54f69226388203 Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Sat, 28 Mar 2026 17:40:02 +0000 Subject: commitquery: Make a reusable engine thingy --- commitquery/context.go | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'commitquery/context.go') 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] +} -- cgit v1.3.1-10-gc9f91