@internal
(index: number)
| 1099 | |
| 1100 | /** @internal */ |
| 1101 | _split(index: number): boolean | void { |
| 1102 | if (this.byStart.get(index) || this.byEnd.get(index)) |
| 1103 | return |
| 1104 | |
| 1105 | /* v8 ignore next 2 -- DEBUG is always true in tests */ |
| 1106 | if (DEBUG) |
| 1107 | this.stats.time('_split') |
| 1108 | |
| 1109 | let chunk = this.lastSearchedChunk |
| 1110 | let previousChunk = chunk |
| 1111 | const searchForward = index > chunk.end |
| 1112 | |
| 1113 | while (chunk) { |
| 1114 | if (chunk.contains(index)) |
| 1115 | return this._splitChunk(chunk, index) |
| 1116 | |
| 1117 | chunk = searchForward ? this.byStart.get(chunk.end) : this.byEnd.get(chunk.start) |
| 1118 | |
| 1119 | // Prevent infinite loop (e.g. via empty chunks, where start === end) |
| 1120 | if (chunk === previousChunk) |
| 1121 | return |
| 1122 | |
| 1123 | previousChunk = chunk |
| 1124 | } |
| 1125 | } |
| 1126 | |
| 1127 | /** @internal */ |
| 1128 | _splitChunk(chunk: Chunk, index: number): true { |
no test coverage detected