File tree Expand file tree Collapse file tree 1 file changed +11
-9
lines changed Expand file tree Collapse file tree 1 file changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -36,10 +36,16 @@ public struct CaseInsensitiveDictionary: Sendable {
36
36
return keyLowerCasedDictionary [ key. lowercased ( ) ]
37
37
}
38
38
set {
39
- var newMap = originalDictionary. filter { $0. key. caseInsensitiveCompare ( key) != . orderedSame }
40
- newMap [ key] = newValue
41
- self . originalDictionary = newMap
42
- self . keyLowerCasedDictionary [ key. lowercased ( ) ] = newValue
39
+ let lowerKey = key. lowercased ( )
40
+ if let newValue = newValue {
41
+ keyLowerCasedDictionary [ lowerKey] = newValue
42
+ } else {
43
+ keyLowerCasedDictionary. removeValue ( forKey: lowerKey)
44
+ }
45
+ originalDictionary = originalDictionary. filter { $0. key. lowercased ( ) != lowerKey }
46
+ if let newValue = newValue {
47
+ originalDictionary [ key] = newValue
48
+ }
43
49
}
44
50
}
45
51
@@ -48,11 +54,7 @@ public struct CaseInsensitiveDictionary: Sendable {
48
54
}
49
55
50
56
public func toStringDictionary( ) -> [ String : String ] {
51
- var dict = [ String: String] ( )
52
- for (key, value) in originalDictionary {
53
- dict [ key] = String ( describing: value)
54
- }
55
- return dict
57
+ return originalDictionary. mapValues { String ( describing: $0) }
56
58
}
57
59
58
60
public var count : Int {
You can’t perform that action at this time.
0 commit comments