You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by GitBox <gi...@apache.org> on 2020/02/24 13:19:25 UTC
[GitHub] [lucene-solr] rmuir commented on a change in pull request #1281:
LUCENE-9245: Optimize AutomatonTermsEnum memory and automaton
Operations.getCommonPrefixBytesRef.
rmuir commented on a change in pull request #1281: LUCENE-9245: Optimize AutomatonTermsEnum memory and automaton Operations.getCommonPrefixBytesRef.
URL: https://github.com/apache/lucene-solr/pull/1281#discussion_r383259436
##########
File path: lucene/core/src/java/org/apache/lucene/index/AutomatonTermsEnum.java
##########
@@ -160,17 +161,18 @@ private void setLinear(int position) {
if (maxInterval != 0xff)
maxInterval++;
int length = position + 1; /* position + maxTransition */
- if (linearUpperBound.bytes.length < length)
- linearUpperBound.bytes = new byte[length];
+ if (linearUpperBound == null) {
+ linearUpperBound = new BytesRef(ArrayUtil.oversize(Math.max(length, 16), Byte.BYTES));
+ } else if (linearUpperBound.bytes.length < length) {
+ linearUpperBound.bytes = new byte[ArrayUtil.oversize(length, Byte.BYTES)];
Review comment:
I don't think we should have the additional null check path here. It is not worth it to save 10 bytes :). Let's make linearUpperBound final again. Better to initialize it to `new BytesRef()` if you really want to save 10 bytes for the case that its not used, does not require additional branches in the code, it will just get extended by the length check.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org