diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/RemoteTagCache.cxx | 14 | ||||
-rw-r--r-- | src/client/Subscribe.cxx | 3 | ||||
-rw-r--r-- | src/db/Count.cxx | 12 | ||||
-rw-r--r-- | src/db/DatabasePrint.cxx | 6 | ||||
-rw-r--r-- | src/db/plugins/simple/Directory.cxx | 7 | ||||
-rw-r--r-- | src/db/update/Walk.cxx | 8 | ||||
-rw-r--r-- | src/event/WinSelectBackend.cxx | 8 | ||||
-rw-r--r-- | src/input/plugins/CurlInputPlugin.cxx | 4 | ||||
-rw-r--r-- | src/input/plugins/QobuzClient.cxx | 12 | ||||
-rw-r--r-- | src/lib/curl/Form.cxx | 10 | ||||
-rw-r--r-- | src/neighbor/plugins/UdisksNeighborPlugin.cxx | 4 | ||||
-rw-r--r-- | src/output/Print.cxx | 5 | ||||
-rw-r--r-- | src/output/plugins/WasapiOutputPlugin.cxx | 8 | ||||
-rw-r--r-- | src/sticker/Print.cxx | 4 | ||||
-rw-r--r-- | src/tag/GenParseName.cxx | 5 |
15 files changed, 49 insertions, 61 deletions
diff --git a/src/RemoteTagCache.cxx b/src/RemoteTagCache.cxx index 78e409660..1e75c3a1f 100644 --- a/src/RemoteTagCache.cxx +++ b/src/RemoteTagCache.cxx @@ -42,9 +42,9 @@ RemoteTagCache::Lookup(const std::string &uri) noexcept std::unique_lock<Mutex> lock(mutex); KeyMap::insert_commit_data hint; - auto result = map.insert_check(uri, Item::Hash(), Item::Equal(), hint); - if (result.second) { - auto *item = new Item(*this, uri); + auto [tag, value] = map.insert_check(uri, Item::Hash(), Item::Equal(), hint); + if (value) { + auto item = new Item(*this, uri); map.insert_commit(*item, hint); waiting_list.push_back(*item); lock.unlock(); @@ -70,15 +70,13 @@ RemoteTagCache::Lookup(const std::string &uri) noexcept ItemResolved(*item); return; } - } else if (result.first->scanner) { + } else if (tag->scanner) { /* already scanning this one - no-op */ } else { /* already finished: re-invoke the handler */ - auto &item = *result.first; - - idle_list.erase(waiting_list.iterator_to(item)); - invoke_list.push_back(item); + idle_list.erase(waiting_list.iterator_to(*tag)); + invoke_list.push_back(*tag); ScheduleInvokeHandlers(); } diff --git a/src/client/Subscribe.cxx b/src/client/Subscribe.cxx index 5091a454d..daf18f3ac 100644 --- a/src/client/Subscribe.cxx +++ b/src/client/Subscribe.cxx @@ -34,8 +34,7 @@ Client::Subscribe(const char *channel) noexcept if (num_subscriptions >= MAX_SUBSCRIPTIONS) return Client::SubscribeResult::FULL; - auto r = subscriptions.insert(channel); - if (!r.second) + if (!subscriptions.insert(channel).second) return Client::SubscribeResult::ALREADY; ++num_subscriptions; diff --git a/src/db/Count.cxx b/src/db/Count.cxx index efcda1169..695991c5b 100644 --- a/src/db/Count.cxx +++ b/src/db/Count.cxx @@ -57,9 +57,9 @@ Print(Response &r, TagType group, const TagCountMap &m) noexcept { assert(unsigned(group) < TAG_NUM_OF_ITEM_TYPES); - for (const auto &i : m) { - tag_print(r, group, i.first.c_str()); - PrintSearchStats(r, i.second); + for (const auto &[tag, stats] : m) { + tag_print(r, group, tag.c_str()); + PrintSearchStats(r, stats); } } @@ -68,8 +68,7 @@ stats_visitor_song(SearchStats &stats, const LightSong &song) noexcept { stats.n_songs++; - const auto duration = song.GetDuration(); - if (!duration.IsNegative()) + if (const auto duration = song.GetDuration(); !duration.IsNegative()) stats.total_duration += duration; } @@ -77,8 +76,7 @@ static void CollectGroupCounts(TagCountMap &map, const Tag &tag, const char *value) noexcept { - auto r = map.insert(std::make_pair(value, SearchStats())); - SearchStats &s = r.first->second; + auto &s = map.insert(std::make_pair(value, SearchStats())).first->second; ++s.n_songs; if (!tag.duration.IsNegative()) s.total_duration += tag.duration; diff --git a/src/db/DatabasePrint.cxx b/src/db/DatabasePrint.cxx index f3f604374..46732b3b6 100644 --- a/src/db/DatabasePrint.cxx +++ b/src/db/DatabasePrint.cxx @@ -195,11 +195,11 @@ PrintUniqueTags(Response &r, ConstBuffer<TagType> tag_types, const char *const name = tag_item_names[tag_types.front()]; tag_types.pop_front(); - for (const auto &i : map) { - r.Format("%s: %s\n", name, i.first.c_str()); + for (const auto &[key, tag] : map) { + r.Format("%s: %s\n", name, key.c_str()); if (!tag_types.empty()) - PrintUniqueTags(r, tag_types, i.second); + PrintUniqueTags(r, tag_types, tag); } } diff --git a/src/db/plugins/simple/Directory.cxx b/src/db/plugins/simple/Directory.cxx index 1465922eb..4c7bb2873 100644 --- a/src/db/plugins/simple/Directory.cxx +++ b/src/db/plugins/simple/Directory.cxx @@ -138,13 +138,10 @@ Directory::LookupDirectory(std::string_view _uri) noexcept Directory *d = this; do { - auto s = uri.Split(PathTraitsUTF8::SEPARATOR); - if (s.first.empty()) + auto [name, rest] = uri.Split(PathTraitsUTF8::SEPARATOR); + if (name.empty()) break; - const auto name = s.first; - const auto rest = s.second; - Directory *tmp = d->FindChild(name); if (tmp == nullptr) /* not found */ diff --git a/src/db/update/Walk.cxx b/src/db/update/Walk.cxx index 2e69f411a..88e8fc480 100644 --- a/src/db/update/Walk.cxx +++ b/src/db/update/Walk.cxx @@ -427,21 +427,19 @@ UpdateWalk::DirectoryMakeUriParentChecked(Directory &root, StringView uri(_uri); while (true) { - auto s = uri.Split('/'); - const std::string_view name = s.first; - const auto rest = s.second; + auto [name, rest] = uri.Split('/'); if (rest == nullptr) break; if (!name.empty()) { directory = DirectoryMakeChildChecked(*directory, std::string(name).c_str(), - s.first); + name); if (directory == nullptr) break; } - uri = s.second; + uri = rest; } return directory; diff --git a/src/event/WinSelectBackend.cxx b/src/event/WinSelectBackend.cxx index f1c663919..08fd1ede4 100644 --- a/src/event/WinSelectBackend.cxx +++ b/src/event/WinSelectBackend.cxx @@ -160,10 +160,10 @@ WinSelectBackend::ReadEvents(int timeout_ms) noexcept ApplyReady(write_set, WinSelectEvents::WRITE); ApplyReady(except_set, WinSelectEvents::WRITE); - for (auto &i : items) - if (i.second.events != 0) { - result.Add(i.second.events, i.second.obj); - i.second.events = 0; + for (auto &[key, item] : items) + if (item.events != 0) { + result.Add(item.events, item.obj); + item.events = 0; } return result; diff --git a/src/input/plugins/CurlInputPlugin.cxx b/src/input/plugins/CurlInputPlugin.cxx index 409a2280f..a2c8e505b 100644 --- a/src/input/plugins/CurlInputPlugin.cxx +++ b/src/input/plugins/CurlInputPlugin.cxx @@ -404,8 +404,8 @@ CurlInputStream::CurlInputStream(EventLoop &event_loop, const char *_url, { request_headers.Append("Icy-Metadata: 1"); - for (const auto &i : headers) - request_headers.Append((i.first + ":" + i.second).c_str()); + for (const auto &[key, header] : headers) + request_headers.Append((key + ":" + header).c_str()); } CurlInputStream::~CurlInputStream() noexcept diff --git a/src/input/plugins/QobuzClient.cxx b/src/input/plugins/QobuzClient.cxx index 0e47aee21..92e74c588 100644 --- a/src/input/plugins/QobuzClient.cxx +++ b/src/input/plugins/QobuzClient.cxx @@ -174,8 +174,8 @@ QobuzClient::MakeUrl(const char *object, const char *method, uri += method; QueryStringBuilder q; - for (const auto &i : query) - q(uri, i.first.c_str(), i.second.c_str()); + for (const auto &[key, url] : query) + q(uri, key.c_str(), url.c_str()); q(uri, "app_id", app_id); return uri; @@ -195,11 +195,11 @@ QobuzClient::MakeSignedUrl(const char *object, const char *method, QueryStringBuilder q; std::string concatenated_query(object); concatenated_query += method; - for (const auto &i : query) { - q(uri, i.first.c_str(), i.second.c_str()); + for (const auto &[key, url] : query) { + q(uri, key.c_str(), url.c_str()); - concatenated_query += i.first; - concatenated_query += i.second; + concatenated_query += key; + concatenated_query += url; } q(uri, "app_id", app_id); diff --git a/src/lib/curl/Form.cxx b/src/lib/curl/Form.cxx index 65430641d..5b668ec46 100644 --- a/src/lib/curl/Form.cxx +++ b/src/lib/curl/Form.cxx @@ -36,16 +36,16 @@ EncodeForm(CURL *curl, { std::string result; - for (const auto &i : fields) { + for (const auto &[key, field] : fields) { if (!result.empty()) result.push_back('&'); - result.append(i.first); + result.append(key); result.push_back('='); - if (!i.second.empty()) { - CurlString value(curl_easy_escape(curl, i.second.data(), - i.second.length())); + if (!field.empty()) { + CurlString value( + curl_easy_escape(curl, field.data(), field.length())); if (value) result.append(value); } diff --git a/src/neighbor/plugins/UdisksNeighborPlugin.cxx b/src/neighbor/plugins/UdisksNeighborPlugin.cxx index 46b90d6cf..f5274e04f 100644 --- a/src/neighbor/plugins/UdisksNeighborPlugin.cxx +++ b/src/neighbor/plugins/UdisksNeighborPlugin.cxx @@ -179,8 +179,8 @@ UdisksNeighborExplorer::GetList() const noexcept NeighborExplorer::List result; - for (const auto &i : by_uri) - result.emplace_front(i.second); + for (const auto &[t, r] : by_uri) + result.emplace_front(r); return result; } diff --git a/src/output/Print.cxx b/src/output/Print.cxx index f649bfb52..9f8edf193 100644 --- a/src/output/Print.cxx +++ b/src/output/Print.cxx @@ -40,8 +40,7 @@ printAudioDevices(Response &r, const MultipleOutputs &outputs) ao.GetName(), ao.GetPluginName(), ao.IsEnabled()); - for (const auto &a : ao.GetAttributes()) - r.Format("attribute: %s=%s\n", - a.first.c_str(), a.second.c_str()); + for (const auto &[attribute, value] : ao.GetAttributes()) + r.Format("attribute: %s=%s\n", attribute.c_str(), value.c_str()); } } diff --git a/src/output/plugins/WasapiOutputPlugin.cxx b/src/output/plugins/WasapiOutputPlugin.cxx index a6c1d483b..fc46d439a 100644 --- a/src/output/plugins/WasapiOutputPlugin.cxx +++ b/src/output/plugins/WasapiOutputPlugin.cxx @@ -323,9 +323,11 @@ void WasapiOutput::Enable() { device.reset(); if (enumerate_devices && SafeTry([this]() { EnumerateDevices(); })) { - for (const auto &desc : device_desc) { - FormatNotice(wasapi_output_domain, "Device \"%u\" \"%s\"", - desc.first, desc.second.c_str()); + for (const auto &[device, desc] : device_desc) { + FormatNotice(wasapi_output_domain, + "Device \"%u\" \"%s\"", + device, + desc.c_str()); } } diff --git a/src/sticker/Print.cxx b/src/sticker/Print.cxx index fb7a7a85b..b60325b3c 100644 --- a/src/sticker/Print.cxx +++ b/src/sticker/Print.cxx @@ -31,6 +31,6 @@ sticker_print_value(Response &r, void sticker_print(Response &r, const Sticker &sticker) { - for (const auto &i : sticker.table) - sticker_print_value(r, i.first.c_str(), i.second.c_str()); + for (const auto &[name, val] : sticker.table) + sticker_print_value(r, name.c_str(), val.c_str()); } diff --git a/src/tag/GenParseName.cxx b/src/tag/GenParseName.cxx index 88b0c2997..9c493b48f 100644 --- a/src/tag/GenParseName.cxx +++ b/src/tag/GenParseName.cxx @@ -60,10 +60,7 @@ main(int argc, char **argv) char first = 0; - for (const auto &i : names) { - const std::string_view name = i.first; - const TagType tag = i.second; - + for (const auto &[name, tag] : names) { if (name.front() != first) { if (first != 0) fprintf(out, " break;\n\n"); |