Skip to content

Commit

Permalink
Override ArrayDeque.head to avoid iterator allocation
Browse files Browse the repository at this point in the history
  • Loading branch information
retronym committed Oct 23, 2019
1 parent 41964e4 commit 093d26a
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/library/scala/collection/mutable/ArrayDeque.scala
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ class ArrayDeque[A] protected (
prependAssumingCapacity(elem)
}

override def head: A = apply(0)

@inline private[ArrayDeque] def appendAssumingCapacity(elem: A): this.type = {
array(end) = elem.asInstanceOf[AnyRef]
end = end_+(1)
Expand Down

0 comments on commit 093d26a

Please sign in to comment.