stephencelis / SQLite.swift

A type-safe, Swift-language layer over SQLite3.
MIT License
9.59k stars 1.55k forks source link

Creating a DateFormatter for every Date? #1038

Closed JetForMe closed 3 years ago

JetForMe commented 3 years ago

Just perusing the code, in Foundation.swift, extension Date, it seems a DateFormatter object is created for every Date created. Perhaps that should be static? I believe they're thread-safe once converted, if unmodified.

dennis-alpine commented 3 years ago

If you're referring to the global variable, public var dateFormatter: DateFormatter = { /* return formatter */ }(), it already acts like a static. If it was written as a getter, public var dataFormatter: DateFormatter { /* return formatter */ }, then that wouldn't be good.

JetForMe commented 3 years ago

Oh, sorry, I thought it was part of extension Date, didn't realize it was outside the scope of that. Nevermind!