* Indicates if the string has been changed.
()
| 1352 | * Indicates if the string has been changed. |
| 1353 | */ |
| 1354 | hasChanged(): boolean { |
| 1355 | if (this.intro || this.outro) |
| 1356 | return true |
| 1357 | |
| 1358 | // How much of `original` the chunks visited so far reproduce, which is not |
| 1359 | // the same as how much of it they span: an overwrite covering several |
| 1360 | // chunks stores the whole replacement on the first of them and empties the |
| 1361 | // rest, so a chunk's content has to be compared against the original text |
| 1362 | // at the offset it is emitted at rather than against its own start and end |
| 1363 | let outputIndex = 0 |
| 1364 | let chunk: Chunk | null = this.firstChunk |
| 1365 | |
| 1366 | while (chunk) { |
| 1367 | // Any intro/outro on a chunk means content was inserted |
| 1368 | if (chunk.intro || chunk.outro) |
| 1369 | return true |
| 1370 | |
| 1371 | if (!chunk.edited && chunk.start === outputIndex) { |
| 1372 | // An untouched chunk still at its original offset reproduces the |
| 1373 | // original exactly, so it needs no comparison |
| 1374 | outputIndex = chunk.end |
| 1375 | } |
| 1376 | else { |
| 1377 | // `startsWith` with an offset compares in place, where slicing the |
| 1378 | // original first would allocate on every edited chunk |
| 1379 | if (!this.original.startsWith(chunk.content, outputIndex)) |
| 1380 | return true |
| 1381 | |
| 1382 | outputIndex += chunk.content.length |
| 1383 | } |
| 1384 | |
| 1385 | chunk = chunk.next |
| 1386 | } |
| 1387 | |
| 1388 | return outputIndex !== this.original.length |
| 1389 | } |
| 1390 | |
| 1391 | /** |
| 1392 | * Whether the original range [start, end) has had any of its characters |
nothing calls this directly
no outgoing calls
no test coverage detected