swiftlang/swift

[SR-10858] Bridging NSString-keyed Dictionaries should only set allowsDuplicates if there are non-ASCII (non-NFC?) Strings

Open

#53.248 geöffnet am 7. Juni 2019

Auf GitHub ansehen
 (9 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)Swift (10.719 Forks)batch import
Dictionarygood first issueimprovementstandard library

Repository-Metriken

Stars
 (69.989 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 8T 17h) (510 gemergte PRs in 30 T)

Beschreibung

Previous ID SR-10858
Radar None
Original Reporter @Catfish-Man
Type Improvement
Status In Progress
Resolution
Votes 1
Component/s Standard Library
Labels Improvement, StarterBug
Assignee valeriyvan (JIRA)
Priority Medium

md5: d18df56f9579713f39cb8ff948cf30ca

Issue Description:

Currently we have code like this:

// String and NSString have different concepts of equality, so
// string-keyed NSDictionaries may generate key collisions when bridged
// over to Swift. See rdar://problem/35995647
let handleDuplicates = (Key.self == String.self)
      
result = Dictionary(_unsafeUninitializedCapacity: numElems,
   allowingDuplicates: handleDuplicates) { keys, vals in
        

This is overly conservative. We only actually need to set allowingDuplicates if there are non-NFC NSStrings!

Contributor Guide