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)
| 419 | return op in _UNIT_CODES |
| 420 | |
| 421 | def _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'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 | |
| 442 | def _get_iscased(flags): |
| 443 | if not flags & SRE_FLAG_IGNORECASE: |
no outgoing calls
no test coverage detected
searching dependent graphs…