Commit 1ce4063
committed
Part 1 - Refactor Featurelist
The "feature.h" as is is a bit heavy:
-> We do have a new Allocation of Feature for every feature
-> We do track the pointers in both a hashmap and qlist
-> Each feature QString is created from a UTF-8 char, so each QString needs an allocation too!
Add to that that the evaluation algorightm of feature -> bool (is this on?) - needs to check multiple std::functions
a String Based List lookup for possible dependencies. A roundtrip to a settingslist to check if we ever feature-flip from guardian.
No optimization is possible, even if we mark a Feature with "FeatureCallback_false" - given we construct the list at runtime,
fetch a Feature* via a QString and then check a std::func* - these are too many layers for the compiler to determine "this is always false".
The reality is, the majority of our feature-flags are Fixed and Non Changeable by the time the Compiler has evaluated the defines.
So we are paying a lot to have flexibility we actually never use and we are paying that on every start of the app.
My proposal is to swap this into a "Pay What you need" model with 3 Tiers of FeatureFlags:
-> Static Feature: They are determined at compiletime. i.e "is this windows?" They need no allocation, just live in the data section.
They are constexpr the compiler can do code-elimination on dead codepaths.
-> Runtime Feature: A wrapper around func -> Bool; They are run on every check, i.e "deactivate windows-split-tunnel when mullvad is detected".
-> Dynamic Feature: A simplified version of our current Feature*, it has a func->bool for the base value. Overrides via the dev-menu are possibile.
Also they support overrides from guardian.
As none of these features are QObjects, for FeatureModel i add a "ViewModel" Class FeatureProxy(feature::any) that can take a ref for any feature and expose
a Feature to QML. The API for QML is unchanged, only in c++ land we have to change callers.1 parent ae9d42e commit 1ce4063
17 files changed
Lines changed: 838 additions & 1205 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
26 | | - | |
27 | 25 | | |
28 | 26 | | |
29 | 27 | | |
| |||
78 | 76 | | |
79 | 77 | | |
80 | 78 | | |
81 | | - | |
82 | | - | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
83 | 85 | | |
84 | 86 | | |
85 | 87 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | 23 | | |
27 | 24 | | |
28 | 25 | | |
| |||
This file was deleted.
This file was deleted.
0 commit comments