@@ -206,6 +206,7 @@ sealed abstract class Vector[+A] private[immutable] (private[immutable] final va
206
206
}
207
207
208
208
protected [this ] def prependedAll0 [B >: A ](prefix : collection.IterableOnce [B ], k : Int ): Vector [B ] = {
209
+ // k >= 0, k = prefix.knownSize
209
210
val tinyAppendLimit = 4 + vectorSliceCount
210
211
if (k < tinyAppendLimit /* || k < (this.size >>> Log2ConcatFaster)*/ ) {
211
212
var v : Vector [B ] = this
@@ -217,14 +218,15 @@ sealed abstract class Vector[+A] private[immutable] (private[immutable] final va
217
218
val it = this .iterator
218
219
while (it.hasNext) v = v :+ it.next()
219
220
v
220
- } else if (prefix.knownSize >= 0 && prefix.knownSize < this .size) {
221
- new VectorBuilder [B ].alignTo(prefix.knownSize , this ).addAll(prefix).addAll(this ).result()
221
+ } else if (k < this .size - AlignToFaster ) {
222
+ new VectorBuilder [B ].alignTo(k , this ).addAll(prefix).addAll(this ).result()
222
223
} else super .prependedAll(prefix)
223
224
}
224
225
225
226
protected [this ] def appendedAll0 [B >: A ](suffix : collection.IterableOnce [B ], k : Int ): Vector [B ] = {
227
+ // k >= 0, k = suffix.knownSize
226
228
val tinyAppendLimit = 4 + vectorSliceCount
227
- if (k > 0 && k < tinyAppendLimit) {
229
+ if ( k < tinyAppendLimit) {
228
230
var v : Vector [B ] = this
229
231
suffix match {
230
232
case it : Iterable [_] => it.asInstanceOf [Iterable [B ]].foreach(x => v = v.appended(x))
@@ -236,7 +238,7 @@ sealed abstract class Vector[+A] private[immutable] (private[immutable] final va
236
238
val ri = this .reverseIterator
237
239
while (ri.hasNext) v = v.prepended(ri.next())
238
240
v
239
- } else if (this .size < suffix.knownSize && suffix.isInstanceOf [Vector [_]]) {
241
+ } else if (this .size < k - AlignToFaster && suffix.isInstanceOf [Vector [_]]) {
240
242
val v = suffix.asInstanceOf [Vector [B ]]
241
243
new VectorBuilder [B ].alignTo(this .size, v).addAll(this ).addAll(v).result()
242
244
} else new VectorBuilder [B ].initFrom(this ).addAll(suffix).result()
@@ -2000,6 +2002,7 @@ private[immutable] object VectorInline {
2000
2002
final val WIDTH5 = 1 << BITS5
2001
2003
final val LASTWIDTH = WIDTH << 1 // 1 extra bit in the last level to go up to Int.MaxValue (2^31-1) instead of 2^30:
2002
2004
final val Log2ConcatFaster = 5
2005
+ final val AlignToFaster = 64
2003
2006
2004
2007
type Arr1 = Array [AnyRef ]
2005
2008
type Arr2 = Array [Array [AnyRef ]]
0 commit comments