Removed 150,000 unnecessary boxings. Interesting
things you find when you log all equality tests. git-svn-id: http://lampsvn.epfl.ch/svn-repos/scala/scala/trunk@18731 5e8d7ff9-d8ef-0310-90f0-a4852d11357a
This commit is contained in:
parent
f3205ca1a3
commit
a031d55eda
|
@ -9,7 +9,7 @@ package scala.tools.nsc
|
|||
package util
|
||||
import scala.tools.nsc.io.{AbstractFile, VirtualFile}
|
||||
import scala.collection.mutable.ArrayBuffer
|
||||
import annotation.tailrec
|
||||
import annotation.{ tailrec, switch }
|
||||
|
||||
object SourceFile {
|
||||
// Be very careful touching these.
|
||||
|
@ -22,7 +22,7 @@ object SourceFile {
|
|||
final val CR = '\u000D'
|
||||
final val SU = '\u001A'
|
||||
|
||||
def isLineBreakChar(c: Int) = c match {
|
||||
@inline def isLineBreakChar(c: Char) = (c: @switch) match {
|
||||
case LF|FF|CR|SU => true
|
||||
case _ => false
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ abstract class SourceFile {
|
|||
(content drop offset) startsWith text
|
||||
|
||||
def lineToString(index: Int): String =
|
||||
content drop lineToOffset(index) takeWhile (c => !isLineBreakChar(c)) mkString
|
||||
content drop lineToOffset(index) takeWhile (c => !isLineBreakChar(c.toChar)) mkString
|
||||
|
||||
@tailrec
|
||||
final def skipWhitespace(offset: Int): Int =
|
||||
|
@ -97,7 +97,7 @@ class BatchSourceFile(val file : AbstractFile, val content: Array[Char]) extends
|
|||
if (idx >= length) false else content(idx) match {
|
||||
// don't identify the CR in CR LF as a line break, since LF will do.
|
||||
case CR => (idx + 1 == length) || (content(idx + 1) != LF)
|
||||
case x => isLineBreakChar(x)
|
||||
case x => isLineBreakChar(x.toChar)
|
||||
}
|
||||
|
||||
private lazy val lineIndices: Array[Int] = {
|
||||
|
|
Loading…
Reference in New Issue