mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-26 13:57:06 +00:00
319dec238a23f71ae50c927ae8eae3c0a47f9a91
Maintainer review on storytold/wordcraft#3562: opening_marks reverse-scans the characters before a question or exclamation mark, and ends_clause asked in_address for each one, which scanned every address range, so a paragraph of thousands of addresses followed by a question took quadratic time (about 99 KB: hundreds of ms). address_at() finds the range a byte is in with a binary search over the sorted, disjoint ranges, and also gives ends_clause the range's end without another scan. Behaviour is unchanged (the URL and punctuation regressions still pass). - address_lookup_finds_the_range_a_byte_is_in: boundaries of the lookup - many_addresses_before_a_question_stay_linear: 99 KB of addresses before a question or exclamation (the review's reproducer and two variants), checked for the right issue range and for taking under 75 ms (about 1 to 5 ms now, about 300 ms with a scan per character)
Languages
Rust
99.6%
Python
0.2%
Max
0.1%