Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4680e1af authored by Victor Chang's avatar Victor Chang
Browse files

Add constexpr specifier to read-only flag

constexpr is availble since C++11 and clang can take advantage
of it for a compile-time optimization.

If C++ version older than C++11 is used, we may need to emit
the constexpr specifier conditionally, e.g. using cpp_std specified
in .bp or wrapping it with a C macro.

Bug: 395633959
Test: atest aconfig.test
Change-Id: I826f07ade87847a8b3e188f300aff6907fcd76dd
parent 54e16561
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -237,11 +237,11 @@ inline bool disabled_rw_in_other_namespace() {
    return provider_->disabled_rw_in_other_namespace();
}

inline bool enabled_fixed_ro() {
constexpr inline bool enabled_fixed_ro() {
    return COM_ANDROID_ACONFIG_TEST_ENABLED_FIXED_RO;
}

inline bool enabled_fixed_ro_exported() {
constexpr inline bool enabled_fixed_ro_exported() {
    return COM_ANDROID_ACONFIG_TEST_ENABLED_FIXED_RO_EXPORTED;
}

@@ -549,7 +549,7 @@ inline bool disabled_rw_in_other_namespace() {
    return false;
}

inline bool enabled_fixed_ro() {
constexpr inline bool enabled_fixed_ro() {
    return COM_ANDROID_ACONFIG_TEST_ENABLED_FIXED_RO;
}

@@ -1103,7 +1103,7 @@ public:

extern std::unique_ptr<flag_provider_interface> provider_;

inline bool disabled_fixed_ro() {
constexpr inline bool disabled_fixed_ro() {
    return COM_ANDROID_ACONFIG_TEST_DISABLED_FIXED_RO;
}

@@ -1111,7 +1111,7 @@ inline bool disabled_ro() {
    return false;
}

inline bool enabled_fixed_ro() {
constexpr inline bool enabled_fixed_ro() {
    return COM_ANDROID_ACONFIG_TEST_ENABLED_FIXED_RO;
}

+1 −0
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ public:
extern std::unique_ptr<flag_provider_interface> provider_;

{{ for item in class_elements}}
{{ if not is_test_mode }}{{ if item.is_fixed_read_only }}constexpr {{ endif }}{{ endif -}}
inline bool {item.flag_name}() \{
    {{ -if is_test_mode }}
    return provider_->{item.flag_name}();