unsignedapps / Vexil

Vexil (named for Vexillology) is a Swift package for managing feature flags (also called feature toggles) in a flexible, multi-provider way.
https://vexil.unsignedapps.com
MIT License
115 stars 12 forks source link

Reduce code bloat from `FlagContainer`s #106

Closed KeithBauerANZ closed 1 year ago

KeithBauerANZ commented 1 year ago

📒 Description

A few hundred flags in some nested groups could easily generate a few MB of code for their init/deinit/copy functions. By reducing the stored properties in Flag/FlagGroup to a minimum, we can reduce this bloat to a minimum. By inlining Decorator, the number of heap allocations can remain constant.

🔍 Detailed Design

Entirely API-compatible change (though IMO it could be improved by making some more Flag/FlagGroup properties read-only, and avoiding the need for isKnownUniquelyReferenced)

📓 Documentation Plan

Entirely API-compatible change

🗳 Test Plan

Entirely API-compatible change. Existing tests pass.

🧯 Source Impact

None

✅ Checklist

KeithBauerANZ commented 1 year ago

https://forums.swift.org/t/add-shared-storage-to-property-wrappers/49898 might allow for a better solution in the future, but for now, this is the best option I can see!

sonarcloud[bot] commented 1 year ago

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

No Coverage information No Coverage information
0.0% 0.0% Duplication