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

PERFORMANCE: Lucene.Net.Facet.Taxonomy.WriterCache.CharBlockArray: Compare equality and calculate hash code without allocating #900

Merged
merged 1 commit into from
Jan 19, 2024

Conversation

NightOwl888
Copy link
Contributor

  • You've read the Contributor Guide and Code of Conduct.
  • You've included unit or integration tests for your change, where applicable.
  • You've included inline docs for your change, where applicable.
  • There's an open issue for the PR that you are making. If you'd like to propose a change, please open an issue to discuss the change or find an existing issue.

Summary of the changes (Less than 80 chars)

PERFORMANCE: Lucene.Net.Facet.Taxonomy.WriterCache.CharBlockArray: Compare equality and calculate hash code without allocating

Description

The equality and hash code generation in Lucene relied on Subsequence() to generate the hash code and check for equality. Subsequence always allocates. The prior implementation of equality was actually copying the characters to a StringBuilder (which allocates), then calling StringBuilder.ToString() (which allocates), then comparing using String.Equals(), which only accepts a string.

This has been modified to pass startIndex and length to the CharBlockArray when calculating hash code and comparing for binary string equality. These checks are done in CharBlockArray itself on the original data structure rather than copying characters out to a buffer compare them.

…mpare equality and calculate hash code without allocating, as it is completely unnecessary.
@NightOwl888 NightOwl888 merged commit 11eca1f into apache:master Jan 19, 2024
62 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant