apache / lucene

Apache Lucene open-source search software
https://lucene.apache.org/
Apache License 2.0
2.61k stars 1.02k forks source link

Optimization: Use precalculated IOContexts for withReadAdvice() to not create new instances all the time #13245

Closed uschindler closed 6 months ago

uschindler commented 6 months ago

Followup of #13242: This optimizes the IOContext#withReadAdvice() method to use precalculated instances of IOContext to not create new instances all the time.

uschindler commented 6 months ago

I think last one is shortest. EnumMap would have been fine, but as it is all an internal cache, a simple array on enum's ordinal number is enough (same approach like switch statements on enums use).