mirror of
https://github.com/apple/swift-collections
synced 2026-11-25 04:37:48 +00:00
Merge pull request #703 from inju2403/cleanup/replaceelement-exchange-same-key
[OrderedCollections] Use exchange(_:with:) in replaceElement's equal-key path
This commit is contained in:
1 file changed
+1
-2
+1
-2
@@ -83,8 +83,7 @@ extension OrderedDictionary {
|
||||
// in place. The hash bucket is unchanged, so no rehash is needed.
|
||||
if existingIndex == index {
|
||||
let oldKey = _keys.update(key, at: index)
|
||||
let oldValue = _values[index]
|
||||
_values[index] = value
|
||||
let oldValue = exchange(&_values[index], with: value)
|
||||
_checkInvariants()
|
||||
return (oldKey, oldValue)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user