Permalink
Browse files

Don't wrap an array just to get its length.

Use .length directly, avoiding the allocation of the WrappedArray.
  • Loading branch information...
1 parent ee03302 commit bc997702ef50d8621d12f855ee17819d89c542f1 @retronym retronym committed Feb 24, 2013
View
2 src/compiler/scala/tools/ant/sabbus/ScalacFork.scala
@@ -119,7 +119,7 @@ class ScalacFork extends ScalaMatchingTask with ScalacShared with TaskArgs {
return
if (includedFiles.nonEmpty)
- log("Compiling %d file%s to %s".format(includedFiles.size, plural(includedFiles.size), destinationDir))
+ log("Compiling %d file%s to %s".format(includedFiles.length, plural(includedFiles.length), destinationDir))
argfile foreach (x => log("Using argfile file: @" + x))
View
4 src/compiler/scala/tools/ant/sabbus/Use.scala
@@ -53,9 +53,9 @@ class Use extends ScalaMatchingTask {
compiler.settings.d,
mapper
) map (new File(sourceDir.get, _))
- if (includedFiles.size > 0)
+ if (includedFiles.length > 0)
try {
- log("Compiling " + includedFiles.size + " file" + (if (includedFiles.size > 1) "s" else "") + " to " + compiler.settings.d.getAbsolutePath)
+ log("Compiling " + includedFiles.length + " file" + (if (includedFiles.length > 1) "s" else "") + " to " + compiler.settings.d.getAbsolutePath)
val (errors, warnings) = compiler.compile(includedFiles)
if (errors > 0)
sys.error("Compilation failed with " + errors + " error" + (if (errors > 1) "s" else "") + ".")
View
6 src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala
@@ -881,9 +881,9 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM {
}
def ubytesToCharArray(bytes: Array[Byte]): Array[Char] = {
- val ca = new Array[Char](bytes.size)
+ val ca = new Array[Char](bytes.length)
var idx = 0
- while(idx < bytes.size) {
+ while(idx < bytes.length) {
val b: Byte = bytes(idx)
assert((b & ~0x7f) == 0)
ca(idx) = b.asInstanceOf[Char]
@@ -900,7 +900,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters with GenJVMASM {
var prevOffset = 0
var offset = 0
var encLength = 0
- while(offset < bSeven.size) {
+ while(offset < bSeven.length) {
val deltaEncLength = (if(bSeven(offset) == 0) 2 else 1)
val newEncLength = encLength.toLong + deltaEncLength
if(newEncLength >= 65535) {
View
2 src/compiler/scala/tools/nsc/util/JavaCharArrayReader.scala
@@ -35,7 +35,7 @@ class JavaCharArrayReader(buf: IndexedSeq[Char], start: Int, /* startline: int,
ch match {
case '\t' =>
case CR =>
- if (bp < buf.size && buf(bp) == LF) {
+ if (bp < buf.length && buf(bp) == LF) {
ch = LF
bp += 1
}
View
2 src/library/scala/Array.scala
@@ -240,7 +240,7 @@ object Array extends FallbackArrayBuilding {
*/
def concat[T: ClassTag](xss: Array[T]*): Array[T] = {
val b = newBuilder[T]
- b.sizeHint(xss.map(_.size).sum)
+ b.sizeHint(xss.map(_.length).sum)
for (xs <- xss) b ++= xs
b.result()
}
View
2 src/library/scala/collection/mutable/FlatHashTable.scala
@@ -77,7 +77,7 @@ trait FlatHashTable[A] extends FlatHashTable.HashUtils[A] {
assert(size >= 0)
table = new Array(capacity(sizeForThreshold(size, _loadFactor)))
- threshold = newThreshold(_loadFactor, table.size)
+ threshold = newThreshold(_loadFactor, table.length)
seedvalue = in.readInt()
View
2 src/library/scala/collection/mutable/HashTable.scala
@@ -96,7 +96,7 @@ trait HashTable[A, Entry >: Null <: HashEntry[A, Entry]] extends HashTable.HashU
val smDefined = in.readBoolean()
table = new Array(capacity(sizeForThreshold(_loadFactor, size)))
- threshold = newThreshold(_loadFactor, table.size)
+ threshold = newThreshold(_loadFactor, table.length)
if (smDefined) sizeMapInit(table.length) else sizemap = null
View
2 src/reflect/scala/reflect/io/VirtualFile.scala
@@ -39,7 +39,7 @@ class VirtualFile(val name: String, override val path: String) extends AbstractF
/** Returns null. */
def file: JFile = null
- override def sizeOption: Option[Int] = Some(content.size)
+ override def sizeOption: Option[Int] = Some(content.length)
def input : InputStream = new ByteArrayInputStream(content)

0 comments on commit bc99770

Please sign in to comment.