Perform Schlinkert pruning both forwards and reverse, picking whichever saves more words #43
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Performs Schlinkert prune on given word list in both the direction it was provided and in reverse. Why in reverse? Because (a) that is still a valid way to make a list uniquely decodable and (b) in some cases it saves more words from the original list (BIPS39 English word list is such an example).
BIPS 39 word list as an example
If you perform a Schlinkert prune on the BIPS39 list in its given order, 1911 words are saved. If you reverse all words on the BIPS39 list and run a Schlinkert prune, 2011 words are saved.
With this PR, when a user tells Tidy to do a Schlinkert prune (
-K
), it now does it in both directions and then actually executes whichever the one saves more words. Cool!Carefully reversing words with accented characters
Use graphemes!
Downsides
It does roughly double the time it takes to run a Schlinkert prune. But I think it's worth it if it does save more words. Tidy isn't built for speed, its built for thoroughness.