New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Range.head is 6x slower than Range.start #6521
Comments
Imported From: https://issues.scala-lang.org/browse/SI-6521?orig=1 |
@dlwh said: One line change: index 92ea5d3..ab303dd 100644
--- a/src/library/scala/collection/immutable/Range.scala
+++ b/src/library/scala/collection/immutable/Range.scala
@@ -78,6 +78,7 @@ extends scala.collection.AbstractSeq[Int]
final val terminalElement = start + numRangeElements * step
override def last = if (isEmpty) Nil.last else lastElement
+ override def head = if (isEmpty) Nil.head else start
override def min[A1 >: Int](implicit ord: Ordering[A1]): Int =
if (ord eq Ordering.Int) { |
@adriaanm said: |
@adriaanm said: |
@JamesIry said: |
@adriaanm said (edited on Feb 9, 2013 9:48:35 PM UTC): See scala/scala#2103. |
consider the following:
This runs in 4100ms on my machine. If you replace head with "start" it's 690ms
I'm making a pull request. One line change.
The text was updated successfully, but these errors were encountered: