-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unit.swift Store units #2371
Unit.swift Store units #2371
Conversation
Store units so each is only created once Remove redundant initializers
Foundation/Unit.swift
Outdated
|
||
// Store is private, access members by `stored(at:)` | ||
// Set members by `stored(_,at:)` | ||
private static var ObjectStore = [Unit?](repeating: nil, count: StoreIndex.max) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style: lowercase. objectStore
. Maybe cachedDimensions
, storedDimensions
?
Foundation/Unit.swift
Outdated
private static var ObjectStore = [Unit?](repeating: nil, count: StoreIndex.max) | ||
|
||
fileprivate static func stored(at index: StoreIndex) -> Unit? { | ||
return ObjectStore[index.rawValue] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These aren't thread-safe, and likely need a lock.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@itaiferber what do you think?
@swift-ci please test |
@e78l Are you still interested in this patch? |
@swift-ci please test Linux |
1 similar comment
@swift-ci please test Linux |
Hoping to push the changes this week |
1451951
to
2262826
Compare
The Swift project moved the default branch to More detail about the branch update - https://forums.swift.org/t/updating-branch-names/40412 |
Reduced code size some w/single initializer in Dimension extension (vs 1 init/Unit* class). Added to size with big enum (stats off Ubuntu below) and other minor changes.
This would be a first step in the Measurement+DateComponents formatter implementation I would like to propose: e78l/swift-corelibs-foundation@613b64b
After PR:
text data bss dec hex filename
8773109 386873 151560 9311542 8e1536 libFoundation.so
Before PR, off 17912de
text data bss dec hex filename
8711549 386873 151528 9249950 8d249e libFoundation.so