Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions lib/src/list/built_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,7 @@ abstract class BuiltList<E> implements Iterable<E>, BuiltIterable<E> {
/// A `BuiltList` is only equal to another `BuiltList` with equal elements in
/// the same order. Then, the `hashCode` is guaranteed to be the same.
@override
int get hashCode {
_hashCode ??= hashObjects(_list);
return _hashCode!;
}
int get hashCode => _hashCode ??= hashObjects(_list);

/// Deep equality.
///
Expand All @@ -79,7 +76,11 @@ abstract class BuiltList<E> implements Iterable<E>, BuiltIterable<E> {
if (identical(other, this)) return true;
if (other is! BuiltList) return false;
if (other.length != length) return false;
if (other.hashCode != hashCode) return false;
if (_hashCode != null &&
other._hashCode != null &&
_hashCode != other._hashCode) {
return false;
}
for (var i = 0; i != length; ++i) {
if (other[i] != this[i]) return false;
Copy link
Author

@lrhn lrhn Jan 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For curiosity: This is the opposite order of what the platform collections otherwise use. For example. contains will use this[i] == needle as a test, not the other way around.
Is there a reason this is not this[i] == other[i]?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No reason that I can remember :)

}
Expand Down