Skip to content

Commit 5088c40

Browse files
committed
Iterator micro opts
Add final methods for iterator and isEmpty, which don't make sense to override.
1 parent 4d39d4f commit 5088c40

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/library/scala/collection/Iterator.scala

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ trait Iterator[+A] extends IterableOnce[A] with IterableOnceOps[A, Iterator, Ite
9191
*/
9292
@throws[NoSuchElementException]
9393
def next(): A
94-
def iterator = this
94+
95+
@inline final def iterator = this
9596

9697
/** Wraps the value of `next()` in an option.
9798
*
@@ -431,7 +432,10 @@ trait Iterator[+A] extends IterableOnce[A] with IterableOnceOps[A, Iterator, Ite
431432
-1
432433
}
433434

434-
final def length: Int = size
435+
@inline final def length: Int = size
436+
437+
@deprecatedOverriding("isEmpty is defined as !hasNext; override hasNext instead", "2.13.0")
438+
override def isEmpty: Boolean = !hasNext
435439

436440
def filter(p: A => Boolean): Iterator[A] = filterImpl(p, isFlipped = false)
437441

0 commit comments

Comments
 (0)