settings: key check with string view

make our string comparisons nicer
also clean-up namespaces for storage access
This commit is contained in:
Maxim Prokhorov
2022-08-29 04:09:58 +03:00
parent deffe551ed
commit 3e36438748
34 changed files with 220 additions and 203 deletions

View File

@@ -2312,10 +2312,10 @@ void _lightApiSetup() {
namespace {
bool _lightWebSocketOnKeyCheck(const char* key, JsonVariant&) {
return (strncmp(key, "light", 5) == 0)
|| (strncmp(key, "use", 3) == 0)
|| (strncmp(key, "lt", 2) == 0);
bool _lightWebSocketOnKeyCheck(espurna::StringView key, const JsonVariant&) {
return espurna::settings::query::samePrefix(key, STRING_VIEW("light"))
|| espurna::settings::query::samePrefix(key, STRING_VIEW("use"))
|| espurna::settings::query::samePrefix(key, STRING_VIEW("lt"));
}
void _lightWebSocketStatus(JsonObject& root) {