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

use inline comparison operators instead of strings.Compare #1398

Merged

Conversation

tylerkovacs
Copy link
Contributor

In the comments from strings.Compare:

// Compare is included only for symmetry with package bytes.
// It is usually clearer and always faster to use the built-in
// string comparison operators ==, <, >, and so on.

And another comment within the implementation:

// NOTE(rsc): This function does NOT call the runtime cmpstring function,
// because we do not want to provide any performance justification for
// using strings.Compare. Basically no one should use strings.Compare.

In the comments from strings.Compare:

// Compare is included only for symmetry with package bytes.
// It is usually clearer and always faster to use the built-in
// string comparison operators ==, <, >, and so on.

And another comment within the implementation:

// NOTE(rsc): This function does NOT call the runtime cmpstring function,
// because we do not want to provide any performance justification for
// using strings.Compare. Basically no one should use strings.Compare.
@tylerkovacs
Copy link
Contributor Author

tylerkovacs commented May 20, 2020

I ran a few tests and average sort time was about 8% faster for sorting 1,000,000 DocumentMatches. Results were quite variable though so I'm not sure the results are predictable. Still, the comments from the source were enough to convince me that this change seemed worthwhile.

Copy link
Member

@abhinavdangeti abhinavdangeti 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 contribution @tylerkovacs .
This looks good to me.

@abhinavdangeti abhinavdangeti merged commit f0ded11 into blevesearch:master May 20, 2020
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.

None yet

3 participants