From 5b92d5076a0be89945fa0fc722749dd5fbfcdf4c Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 14 Jun 2019 10:53:46 -0400 Subject: Common: Use fmt where applicable Begins the transition to using fmt for string formatting where applicable. Given fmt supports formatting std::string instances out of the box, we can remove now-unnecessary calls to .c_str() and .data(). Note that this change does not touch the actual logging subsystem aside from converting the final StringFromFormat call in the process over to fmt::format. Given our logging system is heavily used throughout the entire codebase, and converting that over will be quite a large change by itself, this will be tackled near the end of the conversion process. --- Source/Core/Common/CDUtils.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'Source/Core/Common/CDUtils.cpp') diff --git a/Source/Core/Common/CDUtils.cpp b/Source/Core/Common/CDUtils.cpp index 297934ba7c..fb67d076c6 100644 --- a/Source/Core/Common/CDUtils.cpp +++ b/Source/Core/Common/CDUtils.cpp @@ -9,6 +9,8 @@ #include #include +#include + #include "Common/CDUtils.h" #include "Common/Common.h" #include "Common/CommonTypes.h" @@ -134,20 +136,23 @@ std::vector GetCDDevices() } #else // checklist: /dev/cdrom, /dev/dvd /dev/hd?, /dev/scd? /dev/sr? -static struct +struct CheckListEntry { const char* format; unsigned int num_min; unsigned int num_max; -} checklist[] = { +}; + +constexpr CheckListEntry checklist[] = { #ifdef __linux__ - {"/dev/cdrom", 0, 0}, {"/dev/dvd", 0, 0}, {"/dev/hd%c", 'a', 'z'}, - {"/dev/scd%d", 0, 27}, {"/dev/sr%d", 0, 27}, + {"/dev/cdrom", 0, 0}, {"/dev/dvd", 0, 0}, {"/dev/hd{}", 'a', 'z'}, + {"/dev/scd{}", 0, 27}, {"/dev/sr{}", 0, 27}, #else - {"/dev/acd%d", 0, 27}, - {"/dev/cd%d", 0, 27}, + {"/dev/acd{}", 0, 27}, + {"/dev/cd{}", 0, 27}, #endif - {nullptr, 0, 0}}; + {nullptr, 0, 0}, +}; // Returns true if a device is a block or char device and not a symbolic link static bool IsDevice(const std::string& source_name) @@ -189,7 +194,7 @@ std::vector GetCDDevices() { for (unsigned int j = checklist[i].num_min; j <= checklist[i].num_max; ++j) { - std::string drive = StringFromFormat(checklist[i].format, j); + std::string drive = fmt::format(checklist[i].format, j); if (IsCDROM(drive)) { drives.push_back(std::move(drive)); -- cgit v1.2.3