diff options
Diffstat (limited to 'src')
5 files changed, 23 insertions, 16 deletions
diff --git a/src/library/scala/collection/LinearSeqOptimized.scala b/src/library/scala/collection/LinearSeqOptimized.scala index 0f0a405a85..81cccea519 100755 --- a/src/library/scala/collection/LinearSeqOptimized.scala +++ b/src/library/scala/collection/LinearSeqOptimized.scala @@ -12,6 +12,7 @@ import generic._ import mutable.ListBuffer import immutable.List import scala.util.control.Breaks._ +import scala.annotation.tailrec /** A template trait for linear sequences of type `LinearSeq[A]` which optimizes * the implementation of several methods under the assumption of fast linear access. @@ -247,14 +248,17 @@ trait LinearSeqOptimized[+A, +Repr <: LinearSeqOptimized[A, Repr]] extends Linea } override /*SeqLike*/ - def lengthCompare(len: Int): Int = { - var i = 0 - var these = self - while (!these.isEmpty && i <= len) { - i += 1 - these = these.tail + def lengthCompare(len: Int): Int = { + @tailrec def loop(i: Int, xs: Repr): Int = { + if (i == len) + if (xs.isEmpty) 0 else 1 + else if (xs.isEmpty) + -1 + else + loop(i + 1, xs.tail) } - i - len + if (len < 0) 1 + else loop(0, this) } override /*SeqLike*/ diff --git a/src/library/scala/collection/SeqLike.scala b/src/library/scala/collection/SeqLike.scala index f65e2ef9cd..1be0dba29f 100644 --- a/src/library/scala/collection/SeqLike.scala +++ b/src/library/scala/collection/SeqLike.scala @@ -84,13 +84,17 @@ trait SeqLike[+A, +Repr] extends Any with IterableLike[A, Repr] with GenSeqLike[ * if computing `length` is cheap. */ def lengthCompare(len: Int): Int = { - var i = 0 - val it = iterator - while (it.hasNext && i <= len) { - it.next() - i += 1 + if (len < 0) 1 + else { + var i = 0 + val it = iterator + while (it.hasNext) { + if (i == len) return if (it.hasNext) 1 else 0 + it.next() + i += 1 + } + i - len } - i - len } override /*IterableLike*/ def isEmpty: Boolean = lengthCompare(0) == 0 diff --git a/src/library/scala/collection/immutable/Stream.scala b/src/library/scala/collection/immutable/Stream.scala index be2cd91c68..1c461973e4 100644 --- a/src/library/scala/collection/immutable/Stream.scala +++ b/src/library/scala/collection/immutable/Stream.scala @@ -625,7 +625,7 @@ self => * * @example {{{ * $naturalsEx - * naturalsFrom(1) zip naturalsFrom(2) zip take 5 foreach println + * naturalsFrom(1) zip naturalsFrom(2) take 5 foreach println * // prints * // (1,2) * // (2,3) diff --git a/src/partest/scala/tools/partest/PartestDefaults.scala b/src/partest/scala/tools/partest/PartestDefaults.scala index b27ce6ff75..a21c602d14 100644 --- a/src/partest/scala/tools/partest/PartestDefaults.scala +++ b/src/partest/scala/tools/partest/PartestDefaults.scala @@ -21,7 +21,7 @@ object PartestDefaults { def javaCmd = propOrElse("partest.javacmd", "java") def javacCmd = propOrElse("partest.javac_cmd", "javac") def javaOpts = propOrElse("partest.java_opts", "") - def scalacOpts = propOrElse("partest.scalac_opts", "-deprecation") + def scalacOpts = propOrElse("partest.scalac_opts", "") def testBuild = propOrNone("partest.build") def errorCount = propOrElse("partest.errors", "0").toInt diff --git a/src/partest/scala/tools/partest/nest/CompileManager.scala b/src/partest/scala/tools/partest/nest/CompileManager.scala index 188ebf66ed..3d902d6d00 100644 --- a/src/partest/scala/tools/partest/nest/CompileManager.scala +++ b/src/partest/scala/tools/partest/nest/CompileManager.scala @@ -41,7 +41,6 @@ class ExtConsoleReporter(settings: Settings, val writer: PrintWriter) extends Co class TestSettings(cp: String, error: String => Unit) extends Settings(error) { def this(cp: String) = this(cp, _ => ()) - deprecation.value = true nowarnings.value = false encoding.value = "UTF-8" classpath.value = cp |