- /* Compute salink.next and salink.lcpnext.
- *
- * Algorithm adapted from Crochemore et al. 2009:
- * "LPF computation revisited".
- *
- * Note: we cap lcpnext to the maximum match length so that the
- * match-finder need not worry about it later. */
- link[n - 1].next = (input_idx_t)~0U;
- link[n - 1].prev = (input_idx_t)~0U;
- link[n - 1].lcpnext = 0;
- link[n - 1].lcpprev = 0;
- for (input_idx_t r = n - 2; r != (input_idx_t)~0U; r--) {
- input_idx_t t = r + 1;
- input_idx_t l = LCP[t];
- while (t != (input_idx_t)~0 && SA[t] > SA[r]) {
- l = min(l, link[t].lcpnext);
- t = link[t].next;
+ /* Compute salink.next and salink.lcpnext.
+ *
+ * Algorithm adapted from Crochemore et al. 2009:
+ * "LPF computation revisited".
+ *
+ * Note: we cap lcpnext to the maximum match length so that the
+ * match-finder need not worry about it later. */
+ link[n - 1].next = (input_idx_t)~0U;
+ link[n - 1].prev = (input_idx_t)~0U;
+ link[n - 1].lcpnext = 0;
+ link[n - 1].lcpprev = 0;
+ for (input_idx_t r = n - 2; r != (input_idx_t)~0U; r--) {
+ input_idx_t t = r + 1;
+ input_idx_t l = LCP[t];
+ while (t != (input_idx_t)~0 && SA[t] > SA[r]) {
+ l = min(l, link[t].lcpnext);
+ t = link[t].next;
+ }
+ link[r].next = t;
+ link[r].lcpnext = min(l, max_match_len);
+ LZX_ASSERT(t == (input_idx_t)~0U || l <= n - SA[t]);
+ LZX_ASSERT(l <= n - SA[r]);
+ LZX_ASSERT(memcmp(&T[SA[r]], &T[SA[t]], l) == 0);