MCPcopy Index your code
hub / github.com/python/cpython / _generate_overlap_table

Function _generate_overlap_table

Lib/re/_compiler.py:421–440  ·  view source on GitHub ↗

Generate an overlap table for the following prefix. An overlap table is a table of the same size as the prefix which informs about the potential self-overlap for each index in the prefix: - if overlap[i] == 0, prefix[i:] can't overlap prefix[0:...] - if overlap[i] == k with 0 <

(prefix)

Source from the content-addressed store, hash-verified

419 return op in _UNIT_CODES
420
421def _generate_overlap_table(prefix):
422 """
423 Generate an overlap table for the following prefix.
424 An overlap table is a table of the same size as the prefix which
425 informs about the potential self-overlap for each index in the prefix:
426 - if overlap[i] == 0, prefix[i:] can&#x27;t overlap prefix[0:...]
427 - if overlap[i] == k with 0 < k <= i, prefix[i-k+1:i+1] overlaps with
428 prefix[0:k]
429 """
430 table = [0] * len(prefix)
431 for i in range(1, len(prefix)):
432 idx = table[i - 1]
433 while prefix[i] != prefix[idx]:
434 if idx == 0:
435 table[i] = 0
436 break
437 idx = table[idx - 1]
438 else:
439 table[i] = idx + 1
440 return table
441
442def _get_iscased(flags):
443 if not flags & SRE_FLAG_IGNORECASE:

Callers 1

_compile_infoFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…