rust-petname
rust-petname copied to clipboard
Optimise word lists for common operations
This follows on from ideas in #76:
... space could be saved if words were not stored as a static newline-separated string but as something like
(&'static [[u8; 1]], &'static [[u8; 2]], &'static [[u8; 3]], ...)
, i.e. lists of words indexed by length (even more efficient than[&'static str]
because we don't need one reference per word). I hope such a list can be built at compile-time from the newline-separated files.
There are at least a couple of common things that the petname
command-line tool lets you do that might benefit from preprocessing the word lists before they're compiled in, i.e. alliteration, and word length limits:
-a, --alliterate Generate names where each word begins with the same letter
-A, --alliterate-with <LETTER> Generate names where each word begins with the given letter
-l, --letters <LETTERS> Maximum number of letters in each word; 0 for unlimited [default: 0]
Separately, I am thinking about changing the -l, --letters <LETTERS>
option to take a range, e.g. 3-8
. That might have a bearing on how to preprocess the default word lists.
#60 is also relevant here. It may be useful to have lists collated by first letter.