From 5121fadb4f296e7587e48767da023f02c0eff561 Mon Sep 17 00:00:00 2001 From: fearlessTobi Date: Mon, 26 Nov 2018 20:04:18 +0100 Subject: [PATCH] ir:/movie: Replace for-loops with fmt::join --- src/core/hle/service/ir/extra_hid.cpp | 16 ++++------------ src/core/hle/service/ir/ir_user.cpp | 4 ++-- src/core/movie.cpp | 4 +--- 3 files changed, 7 insertions(+), 17 deletions(-) diff --git a/src/core/hle/service/ir/extra_hid.cpp b/src/core/hle/service/ir/extra_hid.cpp index 2a00ac08f8..8568f15a1f 100644 --- a/src/core/hle/service/ir/extra_hid.cpp +++ b/src/core/hle/service/ir/extra_hid.cpp @@ -165,10 +165,8 @@ void ExtraHID::OnDisconnect() { void ExtraHID::HandleConfigureHIDPollingRequest(const std::vector& request) { if (request.size() != 3) { - std::string request_string; - for (auto request_part : request) - request_string += fmt::format("{:02x} ", request_part); - LOG_ERROR(Service_IR, "Wrong request size ({}): {}", request.size(), request_string); + LOG_ERROR(Service_IR, "Wrong request size ({}): {}", request.size(), + fmt::format("{:02x}", fmt::join(request, " "))); return; } @@ -190,11 +188,8 @@ void ExtraHID::HandleReadCalibrationDataRequest(const std::vector& request_b "ReadCalibrationDataRequest has wrong size"); if (request_buf.size() != sizeof(ReadCalibrationDataRequest)) { - std::string request_buf_string; - for (auto request_buf_part : request_buf) - request_buf_string += fmt::format("{:02x} ", request_buf_part); LOG_ERROR(Service_IR, "Wrong request size ({}): {}", request_buf.size(), - request_buf_string); + fmt::format("{:02x}", fmt::join(request_buf, " "))); return; } @@ -228,10 +223,7 @@ void ExtraHID::OnReceive(const std::vector& data) { HandleReadCalibrationDataRequest(data); break; default: - std::string data_string; - for (auto data_part : data) - data_string += fmt::format("{:02x} ", data_part); - LOG_ERROR(Service_IR, "Unknown request: {}", data_string); + LOG_ERROR(Service_IR, "Unknown request: {}", fmt::format("{:02x}", fmt::join(data, " "))); break; } } diff --git a/src/core/hle/service/ir/ir_user.cpp b/src/core/hle/service/ir/ir_user.cpp index c4466a13f8..d6e1bca7b9 100644 --- a/src/core/hle/service/ir/ir_user.cpp +++ b/src/core/hle/service/ir/ir_user.cpp @@ -183,7 +183,7 @@ private: /// Wraps the payload into packet and puts it to the receive buffer void IR_USER::PutToReceive(const std::vector& payload) { - LOG_TRACE(Service_IR, "called, data={}", Common::ArrayToString(payload.data(), payload.size())); + LOG_TRACE(Service_IR, "called, data={}", fmt::format("{:02x}", fmt::join(payload, " "))); std::size_t size = payload.size(); std::vector packet; @@ -361,7 +361,7 @@ void IR_USER::SendIrNop(Kernel::HLERequestContext& ctx) { ErrorSummary::InvalidState, ErrorLevel::Status)); } - LOG_TRACE(Service_IR, "called, data={}", Common::ArrayToString(buffer.data(), size)); + LOG_TRACE(Service_IR, "called, data={}", fmt::format("{:02x}", fmt::join(buffer, " "))); } void IR_USER::ReleaseReceivedData(Kernel::HLERequestContext& ctx) { diff --git a/src/core/movie.cpp b/src/core/movie.cpp index 1374349f68..e103108f73 100644 --- a/src/core/movie.cpp +++ b/src/core/movie.cpp @@ -358,9 +358,7 @@ Movie::ValidationResult Movie::ValidateHeader(const CTMHeader& header, u64 progr return ValidationResult::Invalid; } - std::string revision; - for (auto header_part : header.revision) - revision += fmt::format("{:02x}", header_part); + std::string revision = fmt::format("{:02x}", fmt::join(header.revision, "")); if (!program_id) Core::System::GetInstance().GetAppLoader().ReadProgramId(program_id);