You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Adrien Grand (JIRA)" <ji...@apache.org> on 2018/08/01 17:44:00 UTC

[jira] [Commented] (LUCENE-8433) Add FutureArrays.equals(Object[] a, int aToIndex, Object[] b, int bFromIndex, int bToIndex)

    [ https://issues.apache.org/jira/browse/LUCENE-8433?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16565699#comment-16565699 ] 

Adrien Grand commented on LUCENE-8433:
--------------------------------------

Maintaining this fork array has some cost, yet this particular call site is not performance sensitive nor would FutureArrays be safer (that I know of) or much easier to read, so I'm not convinced we should do it.

> Add FutureArrays.equals(Object[] a, int aToIndex, Object[] b, int bFromIndex, int bToIndex)
> -------------------------------------------------------------------------------------------
>
>                 Key: LUCENE-8433
>                 URL: https://issues.apache.org/jira/browse/LUCENE-8433
>             Project: Lucene - Core
>          Issue Type: Improvement
>            Reporter: Michael Braun
>            Priority: Trivial
>
> Noticed code like the following in TopFieldCollector:
> {code}
>     if (fields1.length > fields2.length) {
>       return false;
>     }
>     return Arrays.asList(fields1).equals(Arrays.asList(fields2).subList(0, fields1.length));
> {code}
> This can be simplified and made more efficient by using Arrays.equals(Object[] a, int aToIndex, Object[] b, int bFromIndex, int bToIndex) , which is only present in Java 9+. (Though it is not taking advantage of any intrinsics like the primitive arrays do, since it uses object equality rather than reference equality).  This can be added as part of FutureArrays.java - this would serve to simplify code. 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org