From 045f971ec662a7d7f8dc9718051cf0835caa6e37 Mon Sep 17 00:00:00 2001 From: Daniel Spiewak Date: Sun, 1 Aug 2010 17:10:35 -0500 Subject: [PATCH] Removed EmptyVector --- src/main/scala/com/codecommit/collection/Vector.scala | 8 ++++---- src/spec/scala/VectorSpecs.scala | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/scala/com/codecommit/collection/Vector.scala b/src/main/scala/com/codecommit/collection/Vector.scala index d7439d6..f17dbe5 100644 --- a/src/main/scala/com/codecommit/collection/Vector.scala +++ b/src/main/scala/com/codecommit/collection/Vector.scala @@ -115,7 +115,7 @@ class Vector[+T] private (val length: Int, trie: Case, tail: Array[AnyRef]) if (length == 0) { throw new IllegalStateException("Can't pop empty vector") } else if (length == 1) { - EmptyVector + Vector.empty } else if (tail.length > 1) { val tail2 = new Array[AnyRef](tail.length - 1) Array.copy(tail, 0, tail2, 0, tail2.length) @@ -154,8 +154,10 @@ object Vector extends SeqFactory[Vector] { private[collection] val EmptyArray = new Array[AnyRef](0) + private[this] val emptyVector = new Vector[Nothing] + @inline - override def empty[A]: Vector[A] = EmptyVector + override def empty[A]: Vector[A] = emptyVector @inline private[collection] def array(elem: AnyRef) = { @@ -165,8 +167,6 @@ object Vector extends SeqFactory[Vector] { } } -object EmptyVector extends Vector[Nothing] - private[collection] object VectorCases { @inline private[this] def copy1(array1: Array[AnyRef], array2: Array[AnyRef]) = { diff --git a/src/spec/scala/VectorSpecs.scala b/src/spec/scala/VectorSpecs.scala index 59d149e..d6d8132 100644 --- a/src/spec/scala/VectorSpecs.scala +++ b/src/spec/scala/VectorSpecs.scala @@ -1,7 +1,7 @@ import org.specs._ import org.scalacheck._ -import com.codecommit.collection.{EmptyVector, Vector} +import com.codecommit.collection.Vector object VectorSpecs extends Specification with ScalaCheck { import Prop._ @@ -93,7 +93,7 @@ object VectorSpecs extends Specification with ScalaCheck { "fail on pop empty vector" in { val caughtExcept = try { - EmptyVector.pop + Vector.empty.pop false } catch { case _: IllegalStateException => true