Skip to content

Commit 093d26a

Browse files
committed
Override ArrayDeque.head to avoid iterator allocation
1 parent 41964e4 commit 093d26a

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/library/scala/collection/mutable/ArrayDeque.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ class ArrayDeque[A] protected (
8888
prependAssumingCapacity(elem)
8989
}
9090

91+
override def head: A = apply(0)
92+
9193
@inline private[ArrayDeque] def appendAssumingCapacity(elem: A): this.type = {
9294
array(end) = elem.asInstanceOf[AnyRef]
9395
end = end_+(1)

0 commit comments

Comments
 (0)