mirror of
https://github.com/xoseperez/espurna.git
synced 2026-03-13 03:37:05 +01:00
settings: const-correctness and simplify prefix search
Cursor is in a weird spot, by being both the pointer to the data and the read-range that is used of specify the range in which we operate Next TODO would be to move even more things to 'const', but that would at least require to rework the cursor object and also remove it from the members list.
This commit is contained in:
@@ -36,15 +36,9 @@ namespace {
|
||||
void deletePrefixes(::settings::query::StringViewIterator prefixes) {
|
||||
std::vector<String> to_purge;
|
||||
|
||||
::settings::internal::foreach([&](::settings::kvs_type::KeyValueResult&& kv) {
|
||||
const auto key = kv.key.read();
|
||||
for (auto it = prefixes.begin(); it != prefixes.end(); ++it) {
|
||||
if (::settings::query::samePrefix(::settings::StringView{key}, (*it))) {
|
||||
to_purge.push_back(std::move(key));
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
::settings::internal::foreach_prefix([&](::settings::StringView, String key, const ::settings::kvs_type::ReadResult&) {
|
||||
to_purge.push_back(std::move(key));
|
||||
}, prefixes);
|
||||
|
||||
for (const auto& key : to_purge) {
|
||||
delSetting(key);
|
||||
|
||||
Reference in New Issue
Block a user