Commit 2b7d583
committed
PI: Fix O(n²) performance in NameObject read/write for pathological names
Three functions had quadratic behavior that caused hangs on PDFs with
extremely long Name objects (e.g. repeatedly mis-encoded UTF-8 names):
- read_until_regex: searched entire accumulated buffer on each 16-byte
chunk instead of only the new chunk, and used bytes concatenation
- NameObject.unnumber: rebuilt entire bytes object on each # replacement
- NameObject.renumber: used out += concatenation in a loop1 parent 2cfcd7e commit 2b7d583
2 files changed
+41
-25
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
254 | 254 | | |
255 | 255 | | |
256 | 256 | | |
257 | | - | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
258 | 261 | | |
259 | | - | |
| 262 | + | |
260 | 263 | | |
261 | | - | |
262 | | - | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
263 | 269 | | |
264 | | - | |
265 | | - | |
266 | | - | |
267 | | - | |
268 | | - | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
269 | 281 | | |
270 | 282 | | |
271 | 283 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
33 | 32 | | |
34 | 33 | | |
35 | 34 | | |
| |||
840 | 839 | | |
841 | 840 | | |
842 | 841 | | |
| 842 | + | |
843 | 843 | | |
844 | 844 | | |
845 | | - | |
846 | | - | |
| 845 | + | |
847 | 846 | | |
848 | 847 | | |
849 | | - | |
| 848 | + | |
850 | 849 | | |
851 | | - | |
852 | | - | |
| 850 | + | |
| 851 | + | |
853 | 852 | | |
854 | 853 | | |
855 | 854 | | |
| |||
873 | 872 | | |
874 | 873 | | |
875 | 874 | | |
876 | | - | |
877 | | - | |
878 | | - | |
879 | | - | |
880 | | - | |
881 | | - | |
882 | | - | |
883 | | - | |
884 | | - | |
885 | | - | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
886 | 890 | | |
887 | 891 | | |
888 | 892 | | |
| |||
0 commit comments