- match_pos = intervals[interval_idx] & POS_MASK;
- if (match_pos == 0) {
- /* Ambiguous case; just don't allow matches with position 0. */
- if (interval_idx != 0)
- intervals[interval_idx] = cur_pos;
+ if (super_ref == 0) {
+ /* In this case, the current interval may be any of:
+ * (1) the root;
+ * (2) an unvisited child of the root;
+ * (3) an interval last visited by suffix 0
+ *
+ * We could avoid the ambiguity with (3) by using an lcp
+ * placeholder value other than 0 to represent "visited", but
+ * it's fastest to use 0. So we just don't allow matches with
+ * position 0. */
+
+ if (ref != 0) /* Not the root? */
+ intervals[ref & POS_MASK] = cur_pos;