@@ -6,6 +6,7 @@ import java.io.{ObjectInputStream, ObjectOutputStream}
6
6
7
7
import scala .collection .mutable .{Builder , ReusableBuilder }
8
8
import scala .annotation .unchecked .uncheckedVariance
9
+ import scala .runtime .ScalaRunTime
9
10
10
11
/** $factoryInfo
11
12
* @define Coll `Vector`
@@ -221,6 +222,7 @@ final class Vector[+A] private[immutable] (private[collection] val startIndex: I
221
222
s.dirty = dirty
222
223
s.gotoPosWritable(focus, idx, focus ^ idx) // if dirty commit changes; go to new pos and prepare for writing
223
224
s.display0(idx & 31 ) = elem.asInstanceOf [AnyRef ]
225
+ ScalaRunTime .releaseFence()
224
226
s
225
227
}
226
228
@@ -239,7 +241,7 @@ final class Vector[+A] private[immutable] (private[collection] val startIndex: I
239
241
}
240
242
241
243
override def prepended [B >: A ](value : B ): Vector [B ] = {
242
- if (endIndex != startIndex) {
244
+ val result = if (endIndex != startIndex) {
243
245
val blockIndex = (startIndex - 1 ) & ~ 31
244
246
val lo = (startIndex - 1 ) & 31
245
247
@@ -314,10 +316,12 @@ final class Vector[+A] private[immutable] (private[collection] val startIndex: I
314
316
s.display0 = elems
315
317
s
316
318
}
319
+ ScalaRunTime .releaseFence()
320
+ result
317
321
}
318
322
319
323
override def appended [B >: A ](value : B ): Vector [B ] = {
320
- if (endIndex != startIndex) {
324
+ val result = if (endIndex != startIndex) {
321
325
val blockIndex = endIndex & ~ 31
322
326
val lo = endIndex & 31
323
327
@@ -376,6 +380,8 @@ final class Vector[+A] private[immutable] (private[collection] val startIndex: I
376
380
s.display0 = elems
377
381
s
378
382
}
383
+ ScalaRunTime .releaseFence()
384
+ result
379
385
}
380
386
381
387
@@ -512,6 +518,7 @@ final class Vector[+A] private[immutable] (private[collection] val startIndex: I
512
518
s.gotoPosWritable(focus, blockIndex, focus ^ blockIndex)
513
519
s.preClean(d)
514
520
s.cleanLeftEdge(cutIndex - shift)
521
+ ScalaRunTime .releaseFence()
515
522
s
516
523
}
517
524
@@ -527,6 +534,7 @@ final class Vector[+A] private[immutable] (private[collection] val startIndex: I
527
534
s.gotoPosWritable(focus, blockIndex, focus ^ blockIndex)
528
535
s.preClean(d)
529
536
s.cleanRightEdge(cutIndex - shift)
537
+ ScalaRunTime .releaseFence()
530
538
s
531
539
}
532
540
@@ -619,6 +627,7 @@ final class VectorBuilder[A]() extends ReusableBuilder[A, Vector[A]] with Vector
619
627
val s = new Vector [A ](0 , size, 0 ) // should focus front or back?
620
628
s.initFrom(this )
621
629
if (depth > 1 ) s.gotoPos(0 , size - 1 ) // we're currently focused to size - 1, not size!
630
+ ScalaRunTime .releaseFence()
622
631
s
623
632
}
624
633
0 commit comments