Skip to content

Commit 1ce4063

Browse files
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

src/cmake/shared-sources.cmake

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ target_sources(shared-sources INTERFACE
2222
${CMAKE_SOURCE_DIR}/src/constants.h
2323
${CMAKE_SOURCE_DIR}/src/constants.cpp
2424
${CMAKE_SOURCE_DIR}/src/settingslist.h
25-
${CMAKE_SOURCE_DIR}/src/feature/featurelist.h
26-
${CMAKE_SOURCE_DIR}/src/feature/experimentalfeaturelist.h
2725
${CMAKE_SOURCE_DIR}/src/addons/addon.cpp
2826
${CMAKE_SOURCE_DIR}/src/addons/addon.h
2927
${CMAKE_SOURCE_DIR}/src/addons/addonapi.cpp
@@ -78,8 +76,12 @@ target_sources(shared-sources INTERFACE
7876
${CMAKE_SOURCE_DIR}/src/env.h
7977
${CMAKE_SOURCE_DIR}/src/errorhandler.cpp
8078
${CMAKE_SOURCE_DIR}/src/errorhandler.h
81-
${CMAKE_SOURCE_DIR}/src/feature/feature.cpp
82-
${CMAKE_SOURCE_DIR}/src/feature/feature.h
79+
${CMAKE_SOURCE_DIR}/src/feature/features.h
80+
${CMAKE_SOURCE_DIR}/src/feature/features.cpp
81+
${CMAKE_SOURCE_DIR}/src/feature/featuretypes.h
82+
${CMAKE_SOURCE_DIR}/src/feature/featuretypes.cpp
83+
${CMAKE_SOURCE_DIR}/src/feature/featureproxy.cpp
84+
${CMAKE_SOURCE_DIR}/src/feature/featureproxy.h
8385
${CMAKE_SOURCE_DIR}/src/feature/taskgetfeaturelist.cpp
8486
${CMAKE_SOURCE_DIR}/src/feature/taskgetfeaturelist.h
8587
${CMAKE_SOURCE_DIR}/src/feature/taskgetfeaturelistworker.cpp

src/cmake/sources.cmake

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ set_property(TARGET mozillavpn-sources PROPERTY INTERFACE_INCLUDE_DIRECTORIES
2020
# VPN Client source files
2121
target_sources(mozillavpn-sources INTERFACE
2222
${CMAKE_CURRENT_SOURCE_DIR}/accessiblenotification.cpp
23-
${CMAKE_CURRENT_SOURCE_DIR}/feature/featurelistcallback.h
24-
${CMAKE_CURRENT_SOURCE_DIR}/feature/featurelist.h
25-
${CMAKE_CURRENT_SOURCE_DIR}/feature/experimentalfeaturelist.h
2623
${CMAKE_CURRENT_SOURCE_DIR}/appimageprovider.h
2724
${CMAKE_CURRENT_SOURCE_DIR}/applistprovider.h
2825
${CMAKE_CURRENT_SOURCE_DIR}/apppermission.cpp

src/feature/experimentalfeaturelist.h

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/feature/feature.cpp

Lines changed: 0 additions & 292 deletions
This file was deleted.

0 commit comments

Comments
 (0)