hollow icon indicating copy to clipboard operation
hollow copied to clipboard

HollowList iterator calls size() on every hasNext

Open DanielThomas opened this issue 7 years ago • 1 comments

HollowList doesn't implement it's own iterator, instead delegating to java.util.AbstractList.Itr and java.util.AbstractList.ListItr. However Itr calls size() on every call to hasNext():

        public boolean hasNext() {
            return cursor != size();
        }

That said, size is also required for checking if a collection is empty, and is called forlast() in Kotlin so maybe keeping size after first access for the list delegate is a better approach?

DanielThomas avatar Nov 17 '18 03:11 DanielThomas

Can this be worked?

somayaj avatar May 26 '21 14:05 somayaj