Skip to content

Commit

Permalink
Fetch handle in _RealmResultsIterator.current lazily (it may never be…
Browse files Browse the repository at this point in the history
… called for a given index)
  • Loading branch information
nielsenko committed Aug 31, 2023
1 parent 6abe028 commit 29ff9f1
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions lib/src/results.dart
Original file line number Diff line number Diff line change
Expand Up @@ -216,18 +216,16 @@ class _RealmResultsIterator<T extends Object?> implements Iterator<T> {
_index = -1;

@override
T get current => _current as T;
T get current => _current ??= _results[_index];

@override
bool moveNext() {
int length = _results.length;
_current = null;
_index++;
if (_index >= length) {
_current = null;
return false;
}
_current = _results[_index];

return true;
}
}

0 comments on commit 29ff9f1

Please sign in to comment.