Skip to content

Commit

Permalink
SI-8589 Performance improvement for ArrayCharSequence.toString
Browse files Browse the repository at this point in the history
  • Loading branch information
jtvoorde committed Jun 19, 2014
1 parent 300db2a commit 099a426
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/library/scala/runtime/SeqCharSequence.scala
Expand Up @@ -41,5 +41,10 @@ final class ArrayCharSequence(val xs: Array[Char], start: Int, end: Int) extends
new ArrayCharSequence(xs, start1, start1 + newlen)
}
}
override def toString = xs drop start take length mkString ""
override def toString = {
val start = math.max(this.start, 0)
val end = math.min(xs.length, start + length)

if (start >= end) "" else new String(xs, start, end - start)
}
}

0 comments on commit 099a426

Please sign in to comment.