8000 Hash table getOrElseUpdate and indexing 2.12 backport [ci: last-only] by l0rinc · Pull Request #5566 · scala/scala · GitHub
[go: up one dir, main page]

Skip to content

Hash table getOrElseUpdate and indexing 2.12 backport [ci: last-only] #5566

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Al 8000 ready on GitHub? Sign in to your account

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
SI-8774 Null link fields in mutable hash maps on removal.
(cherry picked from commit 9a24860)
  • Loading branch information
Carsten Varming authored and l0rinc committed Dec 19, 2016
commit 78b0914fd58f2bd09aa056cc00d67c8c6ce51de6
5 changes: 4 additions & 1 deletion src/library/scala/collection/mutable/HashTable.scala
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ trait HashTable[A, Entry >: Null <: HashEntry[A, Entry]] extends HashTable.HashU
table(h) = e.next
tableSize = tableSize - 1
nnSizeMapRemove(h)
e.next = null
return e
} else {
var e1 = e.next
Expand All @@ -194,6 +195,7 @@ trait HashTable[A, Entry >: Null <: HashEntry[A, Entry]] extends HashTable.HashU
e.next = e1.next
tableSize = tableSize - 1
nnSizeMapRemove(h)
e1.next = null
return e1
}
}
Expand Down Expand Up @@ -227,8 +229,9 @@ trait HashTable[A, Entry >: Null <: HashEntry[A, Entry]] extends HashTable.HashU
var es = iterTable(idx)

while (es != null) {
val next = es.next // Cache next in case f removes es.
f(es.asInstanceOf[Entry])
es = es.next
es = next

while (es == null && idx > 0) {
idx -= 1
Expand Down
2 changes: 2 additions & 0 deletions src/library/scala/collection/mutable/LinkedHashMap.scala
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ class LinkedHashMap[A, B] extends AbstractMap[A, B]
else e.earlier.later = e.later
if (e.later eq null) lastEntry = e.earlier
else e.later.earlier = e.earlier
e.earlier = null // Null references to prevent nepotism
e.later = null
Some(e.value)
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/library/scala/collection/mutable/LinkedHashSet.scala
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ class LinkedHashSet[A] extends AbstractSet[A]
else e.earlier.later = e.later
if (e.later eq null) lastEntry = e.earlier
else e.later.earlier = e.earlier
e.earlier = null // Null references to prevent nepotism
e.later = null
true
}
}
Expand Down
0