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

Unnecessary boxing of IndexOptions enum #375

Closed
theolivenbaum opened this issue Oct 19, 2020 · 1 comment
Closed

Unnecessary boxing of IndexOptions enum #375

theolivenbaum opened this issue Oct 19, 2020 · 1 comment
Labels

Comments

@theolivenbaum
Copy link
Contributor

Found another easy improvement:

There are plenty of calls to IndexOptions.CompareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) in the code, such as this one:

if (outerInstance.fieldInfo.IndexOptions.CompareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) < 0)
{
    // Positions were not indexed:
    return null;
}

The problem is that CompareTo receives an object, which leads to boxing the enum:

image

@theolivenbaum
Copy link
Contributor Author

From a quick glance, this seems to be only happening for the IndexOptions enum:

image

Uploading image.png…

NightOwl888 added a commit to NightOwl888/lucenenet that referenced this issue Nov 3, 2020
…ters so the parameters are not resolved until a condition fails. There are still some calls that do light math and pick items from arrays, but this performance hit in the tests is something we can live with for better production performance. Closes apache#375, closes apache#373, closes apache#372.
NightOwl888 added a commit to NightOwl888/lucenenet that referenced this issue Nov 3, 2020
…with System.Enum.CompareTo() on IndexOptions enum (closes apache#375, closes apache#376)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants