Skip to content

Commit a8d2c26

Browse files
committed
Reuse incoming tuple in immutable.HashMap1.update if it contains the existing key instance
1 parent 8d4122f commit a8d2c26

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

library/src/scala/collection/immutable/HashMap.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ object HashMap extends ImmutableMapFactory[HashMap] with BitOperations.Int {
366366
if (key == this.key) {
367367
if (merger eq null) {
368368
if (this.value.asInstanceOf[AnyRef] eq value.asInstanceOf[AnyRef]) this
369-
else new HashMap1(this.key, hash, value, null)
369+
else new HashMap1(this.key, hash, value, if (this.key.asInstanceOf[AnyRef] eq key.asInstanceOf[AnyRef]) kv else null)
370370
} else if (
371371
(key.asInstanceOf[AnyRef] eq this.key.asInstanceOf[AnyRef]) &&
372372
(value.asInstanceOf[AnyRef] eq this.value.asInstanceOf[AnyRef]) &&

0 commit comments

Comments
 (0)