Skip to content

Commit cc174ce

Browse files
committed
Removing remaining unnecessary .nn
1 parent c365508 commit cc174ce

File tree

9 files changed

+120
-120
lines changed

9 files changed

+120
-120
lines changed

library/src/scala/collection/immutable/RedBlackTree.scala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ private[collection] object RedBlackTree {
226226
else {
227227
val tl = tree.left
228228
if (tl eq null) tree.right
229-
else if (tl.nn.isBlack) balLeft(tree, _tail(tl), tree.right)
229+
else if (tl.isBlack) balLeft(tree, _tail(tl), tree.right)
230230
else tree.redWithLeft(_tail(tree.left))
231231
}
232232
blacken(_tail(tree))
@@ -238,7 +238,7 @@ private[collection] object RedBlackTree {
238238
else {
239239
val tr = tree.right
240240
if (tr eq null) tree.left
241-
else if (tr.nn.isBlack) balRight(tree, tree.left, _init(tr))
241+
else if (tr.isBlack) balRight(tree, tree.left, _init(tr))
242242
else tree.redWithRight(_init(tr))
243243
}
244244
blacken(_init(tree))
@@ -408,7 +408,7 @@ private[collection] object RedBlackTree {
408408
val resultLeft = tree.blackWithRight(newRight_left)
409409
val resultRight = newRight_right.nn.black
410410

411-
newRight.nn.withLeftRight(resultLeft, resultRight)
411+
newRight.withLeftRight(resultLeft, resultRight)
412412
} else {
413413
// tree
414414
// L KV newRight
@@ -976,10 +976,10 @@ private[collection] object RedBlackTree {
976976
def transform[A, B, C](t: Tree[A, B] | Null, f: (A, B) => C): Tree[A, C] | Null =
977977
if(t eq null) null
978978
else {
979-
val k = t.nn.key
980-
val v = t.nn.value
981-
val l = t.nn.left
982-
val r = t.nn.right
979+
val k = t.key
980+
val v = t.value
981+
val l = t.left
982+
val r = t.right
983983
val l2 = transform(l, f)
984984
val v2 = f(k, v)
985985
val r2 = transform(r, f)

library/src/scala/collection/immutable/TreeMap.scala

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,18 +100,18 @@ final class TreeMap[K, +V] private (private val tree: RB.Tree[K, V] | Null)(impl
100100
override def stepper[S <: Stepper[_]](implicit shape: StepperShape[(K, V), S]): S with EfficientSplit =
101101
shape.parUnbox(
102102
scala.collection.convert.impl.AnyBinaryTreeStepper.from[(K, V), RB.Tree[K, V]](
103-
size, tree.nn, _.left.nn, _.right.nn, x => (x.key, x.value)
103+
size, tree, _.left.nn, _.right.nn, x => (x.key, x.value)
104104
)
105105
)
106106

107107
override def keyStepper[S <: Stepper[_]](implicit shape: StepperShape[K, S]): S with EfficientSplit = {
108108
import scala.collection.convert.impl._
109109
type T = RB.Tree[K, V]
110110
val s = shape.shape match {
111-
case StepperShape.IntShape => IntBinaryTreeStepper.from[T] (size, tree.nn, _.left.nn, _.right.nn, _.key.asInstanceOf[Int])
112-
case StepperShape.LongShape => LongBinaryTreeStepper.from[T] (size, tree.nn, _.left.nn, _.right.nn, _.key.asInstanceOf[Long])
113-
case StepperShape.DoubleShape => DoubleBinaryTreeStepper.from[T](size, tree.nn, _.left.nn, _.right.nn, _.key.asInstanceOf[Double])
114-
case _ => shape.parUnbox(AnyBinaryTreeStepper.from[K, T](size, tree.nn, _.left.nn, _.right.nn, _.key))
111+
case StepperShape.IntShape => IntBinaryTreeStepper.from[T] (size, tree, _.left.nn, _.right.nn, _.key.asInstanceOf[Int])
112+
case StepperShape.LongShape => LongBinaryTreeStepper.from[T] (size, tree, _.left.nn, _.right.nn, _.key.asInstanceOf[Long])
113+
case StepperShape.DoubleShape => DoubleBinaryTreeStepper.from[T](size, tree, _.left.nn, _.right.nn, _.key.asInstanceOf[Double])
114+
case _ => shape.parUnbox(AnyBinaryTreeStepper.from[K, T](size, tree, _.left.nn, _.right.nn, _.key))
115115
}
116116
s.asInstanceOf[S with EfficientSplit]
117117
}
@@ -120,10 +120,10 @@ final class TreeMap[K, +V] private (private val tree: RB.Tree[K, V] | Null)(impl
120120
import scala.collection.convert.impl._
121121
type T = RB.Tree[K, V]
122122
val s = shape.shape match {
123-
case StepperShape.IntShape => IntBinaryTreeStepper.from[T] (size, tree.nn, _.left.nn, _.right.nn, _.value.asInstanceOf[Int])
124-
case StepperShape.LongShape => LongBinaryTreeStepper.from[T] (size, tree.nn, _.left.nn, _.right.nn, _.value.asInstanceOf[Long])
125-
case StepperShape.DoubleShape => DoubleBinaryTreeStepper.from[T] (size, tree.nn, _.left.nn, _.right.nn, _.value.asInstanceOf[Double])
126-
case _ => shape.parUnbox(AnyBinaryTreeStepper.from[V, T] (size, tree.nn, _.left.nn, _.right.nn, _.value.asInstanceOf[V]))
123+
case StepperShape.IntShape => IntBinaryTreeStepper.from[T] (size, tree, _.left.nn, _.right.nn, _.value.asInstanceOf[Int])
124+
case StepperShape.LongShape => LongBinaryTreeStepper.from[T] (size, tree, _.left.nn, _.right.nn, _.value.asInstanceOf[Long])
125+
case StepperShape.DoubleShape => DoubleBinaryTreeStepper.from[T] (size, tree, _.left.nn, _.right.nn, _.value.asInstanceOf[Double])
126+
case _ => shape.parUnbox(AnyBinaryTreeStepper.from[V, T] (size, tree, _.left.nn, _.right.nn, _.value.asInstanceOf[V]))
127127
}
128128
s.asInstanceOf[S with EfficientSplit]
129129
}

library/src/scala/collection/mutable/CollisionProofHashMap.scala

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ final class CollisionProofHashMap[K, V](initialCapacity: Int, loadFactor: Double
572572
yIsRed = y.red
573573
x = y.right
574574

575-
if (y.parent.nn eq z) xParent = y
575+
if (y.parent eq z) xParent = y
576576
else {
577577
xParent = y.parent
578578
root = transplant(root, y, y.right.nn)
@@ -729,8 +729,8 @@ final class CollisionProofHashMap[K, V](initialCapacity: Int, loadFactor: Double
729729
case nn: RBNode @uc => (nn.key, nn.hash, nn.value)
730730
}
731731
val n = new RBNode(key, hash, value, red = false, left, right, null)
732-
if(left ne null) left.nn.parent = n
733-
if(right ne null) right.nn.parent = n
732+
if(left ne null) left.parent = n
733+
if(right ne null) right.parent = n
734734
n
735735
}
736736
f(1, size)
@@ -839,7 +839,7 @@ object CollisionProofHashMap extends SortedMapFactory[CollisionProofHashMap] {
839839
var y = x.parent
840840
while ((y ne null) && (x eq y.nn.right)) {
841841
x = y
842-
y = y.nn.parent
842+
y = y.parent
843843
}
844844
y
845845
}
@@ -870,22 +870,22 @@ object CollisionProofHashMap extends SortedMapFactory[CollisionProofHashMap] {
870870
@tailrec def getNode(k: K, h: Int)(implicit ord: Ordering[K]): LLNode[K, V] | Null = {
871871
if(h == hash && eq(k, key) /*ord.compare(k, key) == 0*/) this
872872
else if((next eq null) || (hash > h)) null
873-
else next.nn.getNode(k, h)
873+
else next.getNode(k, h)
874874
}
875875

876876
@tailrec def foreach[U](f: ((K, V)) => U): Unit = {
877877
f((key, value))
878-
if(next ne null) next.nn.foreach(f)
878+
if(next ne null) next.foreach(f)
879879
}
880880

881881
@tailrec def foreachEntry[U](f: (K, V) => U): Unit = {
882882
f(key, value)
883-
if(next ne null) next.nn.foreachEntry(f)
883+
if(next ne null) next.foreachEntry(f)
884884
}
885885

886886
@tailrec def foreachNode[U](f: LLNode[K, V] => U): Unit = {
887887
f(this)
888-
if(next ne null) next.nn.foreachNode(f)
888+
if(next ne null) next.foreachNode(f)
889889
}
890890
}
891891
}

library/src/scala/collection/mutable/HashMap.scala

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ class HashMap[K, V](initialCapacity: Int, loadFactor: Double)
255255
n = n.next
256256
}
257257
if(prev eq null) table(idx) = new Node(key, hash, value, old)
258-
else prev.nn.next = new Node(key, hash, value, prev.nn.next)
258+
else prev.next = new Node(key, hash, value, prev.next)
259259
}
260260
contentSize += 1
261261
null
@@ -410,9 +410,9 @@ class HashMap[K, V](initialCapacity: Int, loadFactor: Double)
410410
n = next
411411
}
412412
lastLow.nn.next = null
413-
if(old ne preLow.nn.next) table(i) = preLow.nn.next.nn
413+
if(old ne preLow.nn.next) table(i) = preLow.nn.next
414414
if(preHigh.nn.next ne null) {
415-
table(i + oldlen) = preHigh.nn.next.nn
415+
table(i + oldlen) = preHigh.nn.next
416416
lastHigh.nn.next = null
417417
}
418418
}
@@ -504,7 +504,7 @@ class HashMap[K, V](initialCapacity: Int, loadFactor: Double)
504504
var i = 0
505505
while(i < len) {
506506
val n = table(i)
507-
if(n ne null) n.nn.foreach(f)
507+
if(n ne null) n.foreach(f)
508508
i += 1
509509
}
510510
}
@@ -514,7 +514,7 @@ class HashMap[K, V](initialCapacity: Int, loadFactor: Double)
514514
var i = 0
515515
while(i < len) {
516516
val n = table(i)
517-
if(n ne null) n.nn.foreachEntry(f)
517+
if(n ne null) n.foreachEntry(f)
518518
i += 1
519519
}
520520
}
@@ -529,7 +529,7 @@ class HashMap[K, V](initialCapacity: Int, loadFactor: Double)
529529
var head = table(bucket)
530530

531531
while ((head ne null) && !p(head.key, head.value)) {
532-
head = head.next.nn
532+
head = head.next
533533
contentSize -= 1
534534
}
535535

@@ -544,7 +544,7 @@ class HashMap[K, V](initialCapacity: Int, loadFactor: Double)
544544
prev.next = next.next
545545
contentSize -= 1
546546
}
547-
next = next.next.nn
547+
next = next.next
548548
}
549549
}
550550

@@ -563,7 +563,7 @@ class HashMap[K, V](initialCapacity: Int, loadFactor: Double)
563563
var n = table(i)
564564
while (n ne null) {
565565
n.value = f(n.key, n.value)
566-
n = n.next.nn
566+
n = n.next
567567
}
568568
i += 1
569569
}

library/src/scala/collection/mutable/HashSet.scala

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -164,12 +164,12 @@ final class HashSet[A](initialCapacity: Int, loadFactor: Double)
164164
while((n ne null) && n.hash <= hash) {
165165
if(n.hash == hash && elem == n.key) return false
166166
prev = n
167-
n = n.nn.next
167+
n = n.next
168168
}
169169
if(prev eq null)
170170
table(idx) = new Node(elem, hash, old)
171171
else
172-
prev.nn.next = new Node(elem, hash, prev.nn.next)
172+
prev.next = new Node(elem, hash, prev.next)
173173
}
174174
contentSize += 1
175175
true
@@ -195,7 +195,7 @@ final class HashSet[A](initialCapacity: Int, loadFactor: Double)
195195
return true
196196
}
197197
prev = next
198-
next = next.nn.next
198+
next = next.next
199199
}
200200
false
201201
}
@@ -283,9 +283,9 @@ final class HashSet[A](initialCapacity: Int, loadFactor: Double)
283283
n = next
284284
}
285285
lastLow.next = null
286-
if(old ne preLow.next) table(i) = preLow.nn.next
286+
if(old ne preLow.next) table(i) = preLow.next
287287
if(preHigh.next ne null) {
288-
table(i + oldlen) = preHigh.nn.next
288+
table(i + oldlen) = preHigh.next
289289
lastHigh.next = null
290290
}
291291
}
@@ -304,7 +304,7 @@ final class HashSet[A](initialCapacity: Int, loadFactor: Double)
304304
var head = table(bucket)
305305

306306
while ((head ne null) && !p(head.key)) {
307-
head = head.nn.next
307+
head = head.next
308308
contentSize -= 1
309309
}
310310

@@ -319,7 +319,7 @@ final class HashSet[A](initialCapacity: Int, loadFactor: Double)
319319
prev.next = next.next
320320
contentSize -= 1
321321
}
322-
next = next.nn.next
322+
next = next.next
323323
}
324324
}
325325

@@ -376,7 +376,7 @@ final class HashSet[A](initialCapacity: Int, loadFactor: Double)
376376
var i = 0
377377
while(i < len) {
378378
val n = table(i)
379-
if(n ne null) n.nn.foreach(f)
379+
if(n ne null) n.foreach(f)
380380
i += 1
381381
}
382382
}

library/src/scala/collection/mutable/LinkedHashMap.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ class LinkedHashMap[K, V]
401401
table(idx) = nnode
402402
} else {
403403
nnode.next = prev.next
404-
prev.nn.next = nnode
404+
prev.next = nnode
405405
}
406406
}
407407
contentSize += 1

library/src/scala/collection/mutable/LinkedHashSet.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ class LinkedHashSet[A]
129129
override def foreach[U](f: A => U): Unit = {
130130
var cur: Entry | Null = firstEntry
131131
while (cur ne null) {
132-
f(cur.nn.key)
133-
cur = cur.nn.later
132+
f(cur.key)
133+
cur = cur.later
134134
}
135135
}
136136

@@ -280,7 +280,7 @@ class LinkedHashSet[A]
280280
lastLow.next = null
281281
if (old ne preLow.next) table(i) = preLow.next.nn
282282
if (preHigh.next ne null) {
283-
table(i + oldlen) = preHigh.next.nn
283+
table(i + oldlen) = preHigh.next
284284
lastHigh.next = null
285285
}
286286
}

library/src/scala/collection/mutable/ListBuffer.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,15 +210,15 @@ class ListBuffer[A]
210210
if (idx < 0 || idx >= len) throw CommonErrors.indexOutOfBounds(index = idx, max = len - 1)
211211
if (idx == 0) {
212212
val newElem = new :: (elem, first.tail)
213-
if (last0.nn eq first) {
213+
if (last0 eq first) {
214214
last0 = newElem
215215
}
216216
first = newElem
217217
} else {
218218
// `p` can not be `null` because the case where `idx == 0` is handled above
219219
val p = locate(idx).nn
220220
val newElem = new :: (elem, p.tail.tail)
221-
if (last0.nn eq p.tail) {
221+
if (last0 eq p.tail) {
222222
last0 = newElem
223223
}
224224
p.asInstanceOf[::[A]].next = newElem
@@ -275,7 +275,7 @@ class ListBuffer[A]
275275
first = nx.tail
276276
if(first.isEmpty) last0 = null
277277
} else {
278-
if(last0.nn eq nx) last0 = p
278+
if(last0 eq nx) last0 = p
279279
p.next = nx.tail
280280
}
281281
len -= 1

0 commit comments

Comments
 (0)