tealdeer-rs / tealdeer

A very fast implementation of tldr in Rust.
https://tealdeer-rs.github.io/tealdeer/
Apache License 2.0
4.17k stars 123 forks source link

Lowercase page names before lookup #227

Closed dbrgn closed 2 years ago

dbrgn commented 2 years ago

This adds another allocation that wasn't necessary before, but the overhead is totally negligible.

Part of #209.

niklasmohrin commented 2 years ago

I wonder why they don't have a make_lowercase 🤔 I agree, the one allocation doesn't matter. However, I think it would be nice to have the code that handles these what-users-enter-vs-what-files-we-are-looking-for logic in one place. Maybe this change here is better fit right after the code where the words are joined with '-'? What do you think?

dbrgn commented 2 years ago

I wonder why they don't have a make_lowercase 🤔

You mean in-place? That won't work, because it might be possible that the lowercased string requires more bytes than the uppercased string (depending on some unicode edge cases). It's not all ASCII 🙂

Maybe this change here is better fit right after the code where the words are joined with '-'? What do you think?

Yeah, that would actually make sense, then the user sees the real page name that was used for the lookup in the error message (if the page wasn't found).