Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimise word lists for common operations #82

Open
allenap opened this issue Nov 19, 2022 · 1 comment
Open

Optimise word lists for common operations #82

allenap opened this issue Nov 19, 2022 · 1 comment

Comments

@allenap
Copy link
Owner

allenap commented Nov 19, 2022

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.

@allenap
Copy link
Owner Author

allenap commented Nov 20, 2022

#60 is also relevant here. It may be useful to have lists collated by first letter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant