Swift.Dictionary should have a tuple sequence initializer

Originator:zwaldowski
Number:rdar://20657017 Date Originated:22-Apr-2015 04:55 PM
Status:Open Resolved:false
Product:Developer Tools Product Version:Swift 1.2 (swiftlang-602.0.49.6)
Classification:Enhancement Reproducible:Sometimes
 
Summary:
Swift.Dictionary conforms to `DictionaryLiteralConvertible`, implementing the necessary `init(dictionaryLiteral:)`. As the internals of a varargs method involves an array, Swift.Dictionary must already support efficiently initializing with external tuple storage.

Steps to Reproduce:
1. Attempt to use functional concepts in Swift (lazy, map, filter) to create a Swift.Dictionary.
2. Be sad.

Expected Results:
One should be able to initialize a dictionary with a sequence of tuples, such as with the expression `Dictionary(lazy(myArray).filter({ … }).map({ … })`.

Actual Results:
One must write their own initializer chaining to `init(minimumCapacity:)` and looping through the sequence, which might not have optimal performance compared to the `NativeDictionaryStorage` stuff used within the literal initializer.

Version:
Swift 1.2 (swiftlang-602.0.49.6), Xcode 6.3.1 (6D1002), Mac OS X 10.10.4 (14E7f)

Notes:


Configuration:
Occurs in all current public versions of Swift.

Attachments:

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!