We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 459fc38 commit e89eb31Copy full SHA for e89eb31
stdlib/public/Observation/Sources/Observation/ObservationRegistrar.swift
@@ -163,12 +163,10 @@ public struct ObservationRegistrar: Sendable {
163
internal mutating func cancel(_ id: Int) {
164
if let observation = observations.removeValue(forKey: id) {
165
for keyPath in observation.properties {
166
- if var ids = lookups[keyPath] {
167
- ids.remove(id)
168
- if ids.count == 0 {
169
- lookups.removeValue(forKey: keyPath)
170
- } else {
171
- lookups[keyPath] = ids
+ if let index = lookups.index(forKey: keyPath) {
+ lookups.values[index].remove(id)
+ if lookups.values[index].isEmpty {
+ lookups.remove(at: index)
172
}
173
174
0 commit comments