[
https://issues.apache.org/jira/browse/LUCENENET-300?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Nicholas Paldino updated LUCENENET-300:
---------------------------------------
Attachment: SupportClass.patch
Before the Equals method iterates through each IEnumerable<T> interface to
determine if the sequences are equal, it checks to see if ICollection or
ICollection<T> is implemented on the instances of IEnumerable<T> represented by
the parameters x and y.
If they both implement one of those interfaces, then the Count property is
retrieved and compared. If that value is not equal, then the sequences cannot
be equal (since they have a different number of elements) and enumerating
through each IEnumerable<T> implementation can be avoided.
This is important for EquatableList<T> instances that have a large number of
elements (N) that are compared to other IEnumerable<T> implementations that
contain around N number of elements (if not many more, and not exactly N), as
it prevent unecessary enumeration of the sequences to determine equality.
This patch doesn't address a specific issue, but rather, addresses an oversight
in the original implementation of EquatableList<T> which should have been
there, given Lucene.NET's concern with performance.
> Optimizing Equals method on EquitableList<T>
> --------------------------------------------
>
> Key: LUCENENET-300
> URL: https://issues.apache.org/jira/browse/LUCENENET-300
> Project: Lucene.Net
> Issue Type: Improvement
> Reporter: Nicholas Paldino
> Priority: Minor
> Attachments: SupportClass.patch
>
>
> The Equals method on EquatableList<T> does not perform a shortcut check to
> see if the lists being compared are of the same length. If they are not,
> then enumeration through the items in the list does not need to be performed
> in order to compare the lists, because they cannot be equal if they do not
> have the same number of elements.
> Patch to follow.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.