From 6ec5089cc9f427bc1bce459cfb669cd51b0bca86 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Tue, 7 Sep 2021 20:58:23 -0700 Subject: [PATCH] remove std::make_pair make_pair is an old C++98 function that can be replaced by modern shorter constructs. Signed-off-by: Rosen Penev --- src/Permission.cxx | 3 +-- src/db/Count.cxx | 2 +- src/db/update/InotifyUpdate.cxx | 3 +-- src/decoder/plugins/FaadDecoderPlugin.cxx | 2 +- src/decoder/plugins/HybridDsdDecoderPlugin.cxx | 2 +- src/lib/cdio/Paranoia.hxx | 4 ++-- src/lib/ffmpeg/Filter.hxx | 4 ++-- src/output/plugins/AlsaOutputPlugin.cxx | 5 ++--- src/sticker/Database.cxx | 2 +- src/time/ISO8601.cxx | 6 +++--- 10 files changed, 15 insertions(+), 18 deletions(-) diff --git a/src/Permission.cxx b/src/Permission.cxx index b86ea84e1..f04bef042 100644 --- a/src/Permission.cxx +++ b/src/Permission.cxx @@ -98,8 +98,7 @@ initPermissions(const ConfigData &config) std::string password(value, separator); unsigned permission = parsePermissions(separator + 1); - permission_passwords.insert(std::make_pair(std::move(password), - permission)); + permission_passwords.emplace(std::move(password), permission); }); } diff --git a/src/db/Count.cxx b/src/db/Count.cxx index 6925440b5..1b34f4f60 100644 --- a/src/db/Count.cxx +++ b/src/db/Count.cxx @@ -78,7 +78,7 @@ static void CollectGroupCounts(TagCountMap &map, const Tag &tag, const char *value) noexcept { - auto &s = map.insert(std::make_pair(value, SearchStats())).first->second; + auto &s = map.emplace(value, SearchStats()).first->second; ++s.n_songs; if (!tag.duration.IsNegative()) s.total_duration += tag.duration; diff --git a/src/db/update/InotifyUpdate.cxx b/src/db/update/InotifyUpdate.cxx index df31b525e..70351c4dd 100644 --- a/src/db/update/InotifyUpdate.cxx +++ b/src/db/update/InotifyUpdate.cxx @@ -109,8 +109,7 @@ static std::map inotify_directories; static void tree_add_watch_directory(WatchDirectory *directory) { - inotify_directories.insert(std::make_pair(directory->descriptor, - directory)); + inotify_directories.emplace(directory->descriptor, directory); } static void diff --git a/src/decoder/plugins/FaadDecoderPlugin.cxx b/src/decoder/plugins/FaadDecoderPlugin.cxx index c5f18d213..33aa380ad 100644 --- a/src/decoder/plugins/FaadDecoderPlugin.cxx +++ b/src/decoder/plugins/FaadDecoderPlugin.cxx @@ -317,7 +317,7 @@ faad_get_file_time(InputStream &is) } } - return std::make_pair(recognized, duration); + return {recognized, duration}; } static void diff --git a/src/decoder/plugins/HybridDsdDecoderPlugin.cxx b/src/decoder/plugins/HybridDsdDecoderPlugin.cxx index 637492db0..4a39235db 100644 --- a/src/decoder/plugins/HybridDsdDecoderPlugin.cxx +++ b/src/decoder/plugins/HybridDsdDecoderPlugin.cxx @@ -160,7 +160,7 @@ FindHybridDsdData(DecoderClient &client, InputStream &input) if (!found_version || !audio_format.IsValid()) throw UnsupportedFile(); - return std::make_pair(audio_format, remaining); + return {audio_format, remaining}; } /* skip this chunk payload */ diff --git a/src/lib/cdio/Paranoia.hxx b/src/lib/cdio/Paranoia.hxx index 596d23666..330f3800b 100644 --- a/src/lib/cdio/Paranoia.hxx +++ b/src/lib/cdio/Paranoia.hxx @@ -85,7 +85,7 @@ public: auto last = cdio_cddap_disc_lastsector(drv); if (first < 0 || last < 0) throw std::runtime_error("Failed to get disc audio sectors"); - return std::make_pair(first, last); + return std::pair(first, last); } gcc_pure @@ -98,7 +98,7 @@ public: auto last = cdio_cddap_track_lastsector(drv, i); if (first < 0 || last < 0) throw std::runtime_error("Invalid track number"); - return std::make_pair(first, last); + return std::pair(first, last); } gcc_pure diff --git a/src/lib/ffmpeg/Filter.hxx b/src/lib/ffmpeg/Filter.hxx index d2e3a38c5..1730930b4 100644 --- a/src/lib/ffmpeg/Filter.hxx +++ b/src/lib/ffmpeg/Filter.hxx @@ -152,7 +152,7 @@ public: if (err < 0) throw MakeFfmpegError(err, "avfilter_graph_parse_ptr() failed"); - return std::make_pair(std::move(inputs), std::move(outputs)); + return {std::move(inputs), std::move(outputs)}; } void ParseSingleInOut(const char *filters, AVFilterContext &in, @@ -165,7 +165,7 @@ public: if (err < 0) throw MakeFfmpegError(err, "avfilter_graph_parse2() failed"); - return std::make_pair(FilterInOut{inputs}, FilterInOut{outputs}); + return {FilterInOut{inputs}, FilterInOut{outputs}}; } void CheckAndConfigure() { diff --git a/src/output/plugins/AlsaOutputPlugin.cxx b/src/output/plugins/AlsaOutputPlugin.cxx index 26b62d568..3b1ebcd15 100644 --- a/src/output/plugins/AlsaOutputPlugin.cxx +++ b/src/output/plugins/AlsaOutputPlugin.cxx @@ -450,10 +450,9 @@ AlsaOutput::GetAttributes() const noexcept const std::lock_guard lock(attributes_mutex); return { - std::make_pair("allowed_formats", - Alsa::ToString(allowed_formats)), + {"allowed_formats", Alsa::ToString(allowed_formats)}, #ifdef ENABLE_DSD - std::make_pair("dop", dop_setting ? "1" : "0"), + {"dop", dop_setting ? "1" : "0"}, #endif }; } diff --git a/src/sticker/Database.cxx b/src/sticker/Database.cxx index f44ed1877..fd633807b 100644 --- a/src/sticker/Database.cxx +++ b/src/sticker/Database.cxx @@ -163,7 +163,7 @@ StickerDatabase::ListValues(std::map &table, ExecuteForEach(s, [s, &table](){ const char *name = (const char *)sqlite3_column_text(s, 0); const char *value = (const char *)sqlite3_column_text(s, 1); - table.insert(std::make_pair(name, value)); + table.emplace(name, value); }); } diff --git a/src/time/ISO8601.cxx b/src/time/ISO8601.cxx index be20ee803..e93def7ac 100644 --- a/src/time/ISO8601.cxx +++ b/src/time/ISO8601.cxx @@ -68,7 +68,7 @@ ParseTimeZoneOffsetRaw(const char *&s) unsigned long value = std::strtoul(s, &endptr, 10); if (endptr == s + 4) { s = endptr; - return std::make_pair(value / 100, value % 100); + return {value / 100, value % 100}; } else if (endptr == s + 2) { s = endptr; @@ -82,7 +82,7 @@ ParseTimeZoneOffsetRaw(const char *&s) s = endptr; } - return std::make_pair(hours, minutes); + return {hours, minutes}; } else throw std::invalid_argument("Failed to parse time zone offset"); } @@ -234,6 +234,6 @@ ParseISO8601(const char *s) if (*s != 0) throw std::invalid_argument("Garbage at end of time stamp"); - return std::make_pair(tp, precision); + return {tp, precision}; #endif /* !_WIN32 */ }