aboutsummaryrefslogtreecommitdiff
path: root/commitquery/query_mark_phase.go
diff options
context:
space:
mode:
Diffstat (limited to 'commitquery/query_mark_phase.go')
-rw-r--r--commitquery/query_mark_phase.go36
1 files changed, 36 insertions, 0 deletions
diff --git a/commitquery/query_mark_phase.go b/commitquery/query_mark_phase.go
new file mode 100644
index 00000000..0814df38
--- /dev/null
+++ b/commitquery/query_mark_phase.go
@@ -0,0 +1,36 @@
+package commitquery
+
+// beginMarkPhase starts one tracked mark-mutation phase.
+func (query *query) beginMarkPhase() {
+ for _, idx := range query.touched {
+ query.nodes[idx].marks = 0
+ }
+
+ query.markPhase++
+ if query.markPhase == 0 {
+ query.markPhase++
+ for i := range query.nodes {
+ query.nodes[i].touchedPhase = 0
+ }
+ }
+
+ query.touched = query.touched[:0]
+}
+
+// clearTouchedMarks clears the provided bits from all nodes touched in the
+// current mark phase.
+func (query *query) clearTouchedMarks(bits markBits) {
+ for _, idx := range query.touched {
+ query.nodes[idx].marks &^= bits
+ }
+}
+
+// trackTouched records one node in the current mark phase.
+func (query *query) trackTouched(idx nodeIndex) {
+ if query.nodes[idx].touchedPhase == query.markPhase {
+ return
+ }
+
+ query.nodes[idx].touchedPhase = query.markPhase
+ query.touched = append(query.touched, idx)
+}