Zum Inhalt springen

Inefficient Membership Test (ARCH9075)

Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.

Key swift.performance.inefficient-membership-test · Severity warning · Category performance

Flags array.contains inside a loop - an O(n) scan per iteration; a Set makes it O(1).

for id in ids {
if blockedList.contains(id) { skip(id) }
}
let blocked = Set(blockedList)
for id in ids where blocked.contains(id) { skip(id) }

Convert the collection to a Set once, outside the loop.