swiftlang/swift

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

Open

#53.248 aperta il 7 giu 2019

Vedi su GitHub
 (9 commenti) (0 reazioni) (0 assegnatari)Swift (10.719 fork)batch import
Dictionarygood first issueimprovementstandard library

Metriche repository

Star
 (69.989 star)
Metriche merge PR
 (Merge medio 8g 17h) (510 PR mergiate in 30 g)

Descrizione

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!

Guida contributor