Repository navigation
Commit 3f2c551
authored
Avoid rescanning for a comment close after unclosed comments
`HTMLExtractor.parse_comment` searches for `-->` (or `--!>`) from each
`<!--` to the end of the raw data. When there is none, it passes `<`
through as data and returns `i + 1`, so the next `<!--` repeats the
same failing scan. A run of n unclosed comments therefore costs O(n^2):
`'<!--' * 32000` (125 KB) takes about 5 seconds to convert and 250 KB
takes about 22 seconds.
If no close exists after some position in `rawdata`, none exists after
any later position in the same string either. The parser now records
the string and position of the last failed search and skips the search
when it would start at or after that position. The string is compared
by identity so the record is never reused for different raw data.
Output is unchanged.1 parent 8bfb9aa commit 3f2c551
4 files changed
Lines changed: 20 additions & 1 deletion
File tree
- docs
- markdown
- tests/test_syntax/blocks
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
| 111 | + | |
111 | 112 | | |
112 | 113 | | |
113 | 114 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
| 33 | + | |
32 | 34 | | |
33 | 35 | | |
34 | 36 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
158 | 158 | | |
159 | 159 | | |
160 | 160 | | |
| 161 | + | |
| 162 | + | |
161 | 163 | | |
162 | 164 | | |
163 | 165 | | |
| |||
359 | 361 | | |
360 | 362 | | |
361 | 363 | | |
362 | | - | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
363 | 371 | | |
| 372 | + | |
364 | 373 | | |
365 | 374 | | |
366 | 375 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1860 | 1860 | | |
1861 | 1861 | | |
1862 | 1862 | | |
| 1863 | + | |
| 1864 | + | |
| 1865 | + | |
| 1866 | + | |
| 1867 | + | |
| 1868 | + | |
| 1869 | + | |
1863 | 1870 | | |
1864 | 1871 | | |
1865 | 1872 | | |
| |||
0 commit comments