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

Remove unnecessary allocation when checking whether to hide argument name hint #7224

Merged
merged 3 commits into from
Jan 10, 2021
Merged

Conversation

jhpratt
Copy link
Member

@jhpratt jhpratt commented Jan 10, 2021

The case-insensitive prefix/suffix check can be performed
character-by-character. This allows the check to be done without having
to allocate a new string. As a side effect, it's also no longer
necessary to convert the entire string to lowercase, as it's done as
needed. As the only case equality we're handling is ASCII, this
operation can be further optimized by using byte equality, rather than
character equality.

cc @SomeoneToIgnore, as it's an update on my PR from yesterday.

The case-insensitive prefix/suffix check can be performed
character-by-character. This allows the check to be done without having
to allocate a new string. As a side effect, it's also no longer
necessary to convert the entire string to lowercase, as it's done as
needed. As the only case equality we're handling is ASCII, this
operation can be further optimized by using byte equality, rather than
character equality.
Copy link
Contributor

@SomeoneToIgnore SomeoneToIgnore left a comment

Choose a reason for hiding this comment

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

Thanks for the follow-up.

I like the idea, let's make it to behave similar to the previous version.

crates/ide/src/inlay_hints.rs Outdated Show resolved Hide resolved
crates/ide/src/inlay_hints.rs Outdated Show resolved Hide resolved
@SomeoneToIgnore
Copy link
Contributor

SomeoneToIgnore commented Jan 10, 2021

bors d+

Don't bother with the underscore if you still think it's not worth it and just merge the PR then.
Thanks!

@bors
Copy link
Contributor

bors bot commented Jan 10, 2021

✌️ jhpratt can now approve this pull request. To approve and merge a pull request, simply reply with bors r+. More detailed instructions are available here.

@jhpratt
Copy link
Member Author

jhpratt commented Jan 10, 2021

bors r+

@bors
Copy link
Contributor

bors bot commented Jan 10, 2021

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.

2 participants