Merge branch 'struc' of git://github.com/neheb/MPD
This commit is contained in:
commit
d4bbb8c851
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
|
|
Loading…
Reference in New Issue