Skip to content

libunicode: optimize char functions for ascii characters #16670

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

Merged
merged 1 commit into from
Aug 23, 2014

Conversation

Swatinem
Copy link
Contributor

I was doing a lot of parsing ascii strings, and the generic bsearch functions in tables.rs came up very high in the profile.
This should avoid calling those functions for simple ASCII range chars.

pub fn is_alphabetic(c: char) -> bool {
('\x41' <= c && c <= '\x5a')
|| ('\x61' <= c && c <= '\x7a')
|| (c > '\x7f' && derived_property::Alphabetic(c))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you using hex escapes instead of the recognizable literal characters?

@lilyball
Copy link
Contributor

These conditionals might read easier as match statements (although I don't know if that will optimize to the same assembly).

@Swatinem
Copy link
Contributor Author

Ok, I amended the patch, now using match expressions. Also specialized is_upper/lowercase in the same way.

For my personal usecase (using str.words() on a ~15M ascii file), it went from ~18% in tables::White_Space to ~7% in u_char::is_whitespace which is a clear win.

The generated assembly is just ~20 instructions, so it should be fine. But I’m by far no pro when it comes to reading assembly :-D

bors added a commit that referenced this pull request Aug 23, 2014
I was doing a lot of parsing ascii strings, and the generic bsearch functions in `tables.rs` came up very high in the profile.
This should avoid calling those functions for simple ASCII range chars.
@bors bors closed this Aug 23, 2014
@bors bors merged commit cb29492 into rust-lang:master Aug 23, 2014
@Swatinem Swatinem deleted the charascii branch November 3, 2021 12:02
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 3, 2024
…kril

Document nvim 0.10 `inlay_hint`

It took me a few hours to figure out how to enable inlay type hints on Nvim 0.10 with `lspconfig`. `rustaceanvim` has already dropped support for them (mrcjkb/rustaceanvim#46 (comment)) and most other plugins, like `rust-tools`, are depreciated in favor of `rustaceanvim`.

This PR documents how to enable the inlay hints on Neovim 0.10 and later. I've tested this and changing the `on_attach` function is the only step that is required.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants