Repository navigation
Various performance gains, shortcuts and bitsets - #303
Conversation
The GraphemeBreakTest.txt is missing a test for this bug, so we create our own using TDD. This bug was found by static analysis, it would be uncommon in practical use, the highest level functions already split or replace errant control characters (newline, tab), escape sequences are iterated over, and even the low-level graphemes functions used by editors also avoid likely control characters.
Merging this PR will improve performance by 61.53%1 warning
Performance Changes
Tip Curious why performance improved? Comment Comparing |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #303 +/- ##
==========================================
+ Coverage 87.84% 88.09% +0.25%
==========================================
Files 41 41
Lines 5625 5654 +29
Branches 1510 1520 +10
==========================================
+ Hits 4941 4981 +40
Misses 319 319
+ Partials 365 354 -11 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
iter_graphemes_reverse()andgrapheme_boundary_before()are migrated to use libwcwidth, showing the most performance gains.should_break()cluster_start_index()gcb_of()andshould_break()get a shortcut for codepoints < 0x300clip()gets a performance boost using GRAPHEME_WINDOW (64)I tested bitsets long ago in python (only) with similar ~1-1.3x results and decided the performance improvement did not improve the readability, and again recently in September and declined again for libwcwidth,
I am now willing to make the tradeoff for the marginal performance win.
Which tables are selected for bitset was chosen by our benchmarks, bisearch is still used for some tables where it performs better. In libwcwidth and python wcwidth, all previously exported codepoint range tables remain, even though they are now sometimes unused in libwcwidth/python+build_ext.