From 9ce26ef4b6fd68c919b23ec76a0367d48fb6ea5e Mon Sep 17 00:00:00 2001 From: jvoisin Date: Sat, 21 May 2022 21:44:47 +0200 Subject: [PATCH] Move to_utf8 from `const std::string&` to `std::string_view` --- components/to_utf8/to_utf8.cpp | 8 ++++---- components/to_utf8/to_utf8.hpp | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/components/to_utf8/to_utf8.cpp b/components/to_utf8/to_utf8.cpp index 7e7d3101fc..6e04db8db4 100644 --- a/components/to_utf8/to_utf8.cpp +++ b/components/to_utf8/to_utf8.cpp @@ -348,7 +348,7 @@ std::string_view Utf8Encoder::getLegacyEnc(std::string_view input) return mImpl.getLegacyEnc(input, BufferAllocationPolicy::UseGrowFactor, mBuffer); } -ToUTF8::FromType ToUTF8::calculateEncoding(const std::string& encodingName) +ToUTF8::FromType ToUTF8::calculateEncoding(std::string_view encodingName) { if (encodingName == "win1250") return ToUTF8::WINDOWS_1250; @@ -357,10 +357,10 @@ ToUTF8::FromType ToUTF8::calculateEncoding(const std::string& encodingName) else if (encodingName == "win1252") return ToUTF8::WINDOWS_1252; else - throw std::runtime_error(std::string("Unknown encoding '") + encodingName + std::string("', see openmw --help for available options.")); + throw std::runtime_error("Unknown encoding '" + std::string(encodingName) + "', see openmw --help for available options."); } -std::string ToUTF8::encodingUsingMessage(const std::string& encodingName) +std::string ToUTF8::encodingUsingMessage(std::string_view encodingName) { if (encodingName == "win1250") return "Using Central and Eastern European font encoding."; @@ -369,5 +369,5 @@ std::string ToUTF8::encodingUsingMessage(const std::string& encodingName) else if (encodingName == "win1252") return "Using default (English) font encoding."; else - throw std::runtime_error(std::string("Unknown encoding '") + encodingName + std::string("', see openmw --help for available options.")); + throw std::runtime_error("Unknown encoding '" + std::string(encodingName) + "', see openmw --help for available options."); } diff --git a/components/to_utf8/to_utf8.hpp b/components/to_utf8/to_utf8.hpp index 037e3ea3bf..918f03aa9f 100644 --- a/components/to_utf8/to_utf8.hpp +++ b/components/to_utf8/to_utf8.hpp @@ -24,8 +24,8 @@ namespace ToUTF8 UseGrowFactor, }; - FromType calculateEncoding(const std::string& encodingName); - std::string encodingUsingMessage(const std::string& encodingName); + FromType calculateEncoding(std::string_view encodingName); + std::string encodingUsingMessage(std::string_view encodingName); class StatelessUtf8Encoder {