summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRex Kerr <ichoran@gmail.com>2016-11-09 00:30:31 -0800
committerRex Kerr <ichoran@gmail.com>2016-11-09 18:00:07 -0800
commite5fd42d60a8eee70e2e4fa1c141557924115763d (patch)
treee644b05513ece978beea7a570db587754cc251bd
parent10c609e750a7089055b126e6231e5ddb2f2e8623 (diff)
downloadscala-e5fd42d60a8eee70e2e4fa1c141557924115763d.tar.gz
scala-e5fd42d60a8eee70e2e4fa1c141557924115763d.tar.bz2
scala-e5fd42d60a8eee70e2e4fa1c141557924115763d.zip
Improved runtime speed for Vector, restoring previous performance.
All calls to Platform.arraycopy were rewritten as java.lang.System.arraycopy to reduce the work that the JIT compiler has to do to produce optimized bytecode that avoids zeroing just-allocated arrays that are about to be copied over. (Tested with -XX:-ReduceBulkZeroing as suggested by retronym.)
-rw-r--r--src/library/scala/collection/immutable/Vector.scala9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/library/scala/collection/immutable/Vector.scala b/src/library/scala/collection/immutable/Vector.scala
index a162fdaaf8..d9d925705f 100644
--- a/src/library/scala/collection/immutable/Vector.scala
+++ b/src/library/scala/collection/immutable/Vector.scala
@@ -11,7 +11,6 @@ package collection
package immutable
import scala.annotation.unchecked.uncheckedVariance
-import scala.compat.Platform
import scala.collection.generic._
import scala.collection.mutable.{Builder, ReusableBuilder}
import scala.collection.parallel.immutable.ParVector
@@ -478,12 +477,12 @@ override def companion: GenericCompanion[Vector] = Vector
// if (array eq null)
// println("OUCH!!! " + right + "/" + depth + "/"+startIndex + "/" + endIndex + "/" + focus)
val a2 = new Array[AnyRef](array.length)
- Platform.arraycopy(array, 0, a2, 0, right)
+ java.lang.System.arraycopy(array, 0, a2, 0, right)
a2
}
private def copyRight(array: Array[AnyRef], left: Int): Array[AnyRef] = {
val a2 = new Array[AnyRef](array.length)
- Platform.arraycopy(array, left, a2, left, a2.length - left)
+ java.lang.System.arraycopy(array, left, a2, left, a2.length - left)
a2
}
@@ -955,7 +954,7 @@ private[immutable] trait VectorPointer[T] {
private[immutable] final def copyOf(a: Array[AnyRef]) = {
val b = new Array[AnyRef](a.length)
- Platform.arraycopy(a, 0, b, 0, a.length)
+ java.lang.System.arraycopy(a, 0, b, 0, a.length)
b
}
@@ -1119,7 +1118,7 @@ private[immutable] trait VectorPointer[T] {
private[immutable] final def copyRange(array: Array[AnyRef], oldLeft: Int, newLeft: Int) = {
val elems = new Array[AnyRef](32)
- Platform.arraycopy(array, oldLeft, elems, newLeft, 32 - math.max(newLeft,oldLeft))
+ java.lang.System.arraycopy(array, oldLeft, elems, newLeft, 32 - math.max(newLeft,oldLeft))
elems
}