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

Optimize equality comparison of two empty string_views #4904

Merged
merged 7 commits into from
Aug 25, 2024

Conversation

YexuanXiao
Copy link
Contributor

@YexuanXiao YexuanXiao commented Aug 22, 2024

Fixes #3310.

@YexuanXiao YexuanXiao requested a review from a team as a code owner August 22, 2024 18:49
@CaseyCarter CaseyCarter added the performance Must go faster label Aug 22, 2024
@StephanTLavavej StephanTLavavej self-assigned this Aug 22, 2024
Copy link
Member

@CaseyCarter CaseyCarter left a comment

Choose a reason for hiding this comment

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

Some minor nits that I'll apply.

benchmarks/src/sv_equal.cpp Outdated Show resolved Hide resolved
benchmarks/src/sv_equal.cpp Outdated Show resolved Hide resolved
benchmarks/CMakeLists.txt Outdated Show resolved Hide resolved
benchmarks/src/sv_equal.cpp Show resolved Hide resolved
@StephanTLavavej StephanTLavavej changed the title Optimize equality comparison of two empty string_views (#3310) Optimize equality comparison of two empty string_views Aug 23, 2024
@StephanTLavavej StephanTLavavej removed their assignment Aug 23, 2024
@StephanTLavavej
Copy link
Member

Thanks, this is great! 😻 I pushed a commit for trivial naming nitpicks, and verified that there's a significant speedup for empty comparisons (I observed 1.7x, from 37.4 ns down to 22.0 ns).

We merge PRs to our GitHub and MSVC-internal repos simultaneously in a semi-manual process, batched up to save time. Your PR will be part of the next batch. I'll post comments here as I prepare this for merging!

@StephanTLavavej StephanTLavavej self-assigned this Aug 25, 2024
@StephanTLavavej
Copy link
Member

I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed.

@StephanTLavavej StephanTLavavej merged commit d1f63f3 into microsoft:main Aug 25, 2024
39 checks passed
@StephanTLavavej
Copy link
Member

Thanks for this significant performance improvement - it's a small change but it affects extremely common operations (both string and string_view). Amazing for a first-time contribution! 😻 🚀 🎉

This is expected to ship in VS 2022 17.12 Preview 3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Must go faster
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Optimize string_view::operator== when comparing 2 empty string_views
3 participants