Skip to content

Commit fd5bc0f

Browse files
committed
[stdlib] Dictionary.values: Replace setter with _modify
This should enable in-place modification of the Values view, which should greatly improve the performance of code like this: dictionary.values[index] = newValue
1 parent 649d310 commit fd5bc0f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

stdlib/public/core/Dictionary.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,8 +1289,11 @@ extension Dictionary {
12891289
get {
12901290
return Values(_dictionary: self)
12911291
}
1292-
set {
1293-
self._variant = newValue._variant
1292+
_modify {
1293+
var values = Values(_variant: _variant)
1294+
_variant = .native(_NativeDictionary())
1295+
yield &values
1296+
self._variant = values._variant
12941297
}
12951298
}
12961299

0 commit comments

Comments
 (0)