diff options
3 files changed, 15 insertions, 8 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala index ba00802af7..67deaf0392 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala @@ -970,9 +970,8 @@ trait Parsers extends NewScanners with MarkupParsers { val cond = surround(LPAREN,RPAREN)(expr(),Literal(true)) newLinesOpt() val thenp = expr() - val elsep = - if (inToken == ELSE) { inNextToken; expr() } - else EmptyTree + val elsep = if (inToken == ELSE) { inNextToken; expr() } + else Literal(()) atPos(pos) { If(cond, thenp, elsep) } case TRY => atPos(inSkipToken) { diff --git a/src/library/scalax/collection/mutable/ArrayBuffer.scala b/src/library/scalax/collection/mutable/ArrayBuffer.scala index e08102afb3..df7f6ba758 100644 --- a/src/library/scalax/collection/mutable/ArrayBuffer.scala +++ b/src/library/scalax/collection/mutable/ArrayBuffer.scala @@ -23,9 +23,7 @@ package scalax.collection.mutable @serializable class ArrayBuffer[A] extends Buffer[A] with Builder[ArrayBuffer, A] with ResizableArray[A] { - def clear() { - size0 = 0 - } + def clear() { reduceToSize(0) } /** Appends a single element to this buffer and returns * the identity of the buffer. It takes constant time. @@ -45,7 +43,14 @@ class ArrayBuffer[A] extends Buffer[A] with Builder[ArrayBuffer, A] with Resizab * @param iter the iterable object. * @return the updated buffer. */ - override def ++=(iter: Iterable[A]) { iter copyToBuffer this } + override def ++=(iter: Iterable[A]) = iter match { + case v: Vector[A] => + val n = v.length + ensureSize(size0 + n) + v.copyToArray(array.asInstanceOf[Array[Any]], n) + case _ => + super.++=(iter) + } /** Prepends a single element to this buffer and return * the identity of the buffer. It takes time linear in diff --git a/src/library/scalax/collection/mutable/ResizableArray.scala b/src/library/scalax/collection/mutable/ResizableArray.scala index 5a9e81f069..93a4c7753a 100644 --- a/src/library/scalax/collection/mutable/ResizableArray.scala +++ b/src/library/scalax/collection/mutable/ResizableArray.scala @@ -72,7 +72,10 @@ trait ResizableArray[A] extends Vector[A] { */ def reduceToSize(sz: Int) { require(sz <= size0) - size0 = sz + while (size0 > sz) { + size0 -= 1 + array(size0) = null + } } /** ensure that the internal array has at n cells */ |