Core/StringExt: Don't pass string_view by ref
https://quuxplusone.github.io/blog/2021/11/09/pass-string-view-by-value/
This commit is contained in:
@@ -49,7 +49,7 @@ namespace Nz
|
||||
}
|
||||
}
|
||||
|
||||
bool IsWavSupported(const std::string_view& extension)
|
||||
bool IsWavSupported(std::string_view extension)
|
||||
{
|
||||
return extension == ".riff" || extension == ".rf64" || extension == ".wav" || extension == ".w64";
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ namespace Nz
|
||||
return DecodeFlacFrameSamples(frame, buffer, samples, 0, frame->header.blocksize);
|
||||
}
|
||||
|
||||
bool IsFlacSupported(const std::string_view& extension)
|
||||
bool IsFlacSupported(std::string_view extension)
|
||||
{
|
||||
return extension == ".flac";
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace Nz
|
||||
return (stream->SetCursorPos(position)) ? 0 : MP3D_E_IOERROR;
|
||||
}
|
||||
|
||||
bool IsMP3Supported(const std::string_view& extension)
|
||||
bool IsMP3Supported(std::string_view extension)
|
||||
{
|
||||
return extension == ".mp3";
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace Nz
|
||||
return FromUtf16String(std::u16string_view(reinterpret_cast<const char16_t*>(wstr), size));
|
||||
}
|
||||
|
||||
static std::wstring To(const std::string_view& str)
|
||||
static std::wstring To(std::string_view str)
|
||||
{
|
||||
std::wstring result;
|
||||
utf8::utf8to16(str.begin(), str.end(), std::back_inserter(result));
|
||||
@@ -81,7 +81,7 @@ namespace Nz
|
||||
return FromUtf32String(std::u32string_view(reinterpret_cast<const char32_t*>(wstr), size));
|
||||
}
|
||||
|
||||
static std::wstring To(const std::string_view& str)
|
||||
static std::wstring To(std::string_view str)
|
||||
{
|
||||
std::wstring result;
|
||||
utf8::utf8to32(str.begin(), str.end(), std::back_inserter(result));
|
||||
@@ -92,12 +92,12 @@ namespace Nz
|
||||
#endif
|
||||
}
|
||||
|
||||
std::size_t ComputeCharacterCount(const std::string_view& str)
|
||||
std::size_t ComputeCharacterCount(std::string_view str)
|
||||
{
|
||||
return utf8::distance(str.data(), str.data() + str.size());
|
||||
}
|
||||
|
||||
bool EndsWith(const std::string_view& lhs, const std::string_view& rhs, CaseIndependent)
|
||||
bool EndsWith(std::string_view lhs, std::string_view rhs, CaseIndependent)
|
||||
{
|
||||
NAZARA_USE_ANONYMOUS_NAMESPACE
|
||||
|
||||
@@ -110,7 +110,7 @@ namespace Nz
|
||||
});
|
||||
}
|
||||
|
||||
bool EndsWith(const std::string_view& lhs, const std::string_view& rhs, UnicodeAware)
|
||||
bool EndsWith(std::string_view lhs, std::string_view rhs, UnicodeAware)
|
||||
{
|
||||
if (lhs.empty())
|
||||
return lhs == rhs;
|
||||
@@ -136,7 +136,7 @@ namespace Nz
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EndsWith(const std::string_view& lhs, const std::string_view& rhs, CaseIndependent, UnicodeAware)
|
||||
bool EndsWith(std::string_view lhs, std::string_view rhs, CaseIndependent, UnicodeAware)
|
||||
{
|
||||
if (lhs.empty())
|
||||
return lhs == rhs;
|
||||
@@ -162,7 +162,7 @@ namespace Nz
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string FromUtf16String(const std::u16string_view& u16str)
|
||||
std::string FromUtf16String(std::u16string_view u16str)
|
||||
{
|
||||
std::string result;
|
||||
utf8::utf16to8(u16str.begin(), u16str.end(), std::back_inserter(result));
|
||||
@@ -170,7 +170,7 @@ namespace Nz
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string FromUtf32String(const std::u32string_view& u32str)
|
||||
std::string FromUtf32String(std::u32string_view u32str)
|
||||
{
|
||||
std::string result;
|
||||
utf8::utf32to8(u32str.begin(), u32str.end(), std::back_inserter(result));
|
||||
@@ -178,14 +178,14 @@ namespace Nz
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string FromWideString(const std::wstring_view& wstr)
|
||||
std::string FromWideString(std::wstring_view wstr)
|
||||
{
|
||||
NAZARA_USE_ANONYMOUS_NAMESPACE
|
||||
|
||||
return WideConverter<sizeof(wchar_t)>::From(wstr.data(), wstr.size());
|
||||
}
|
||||
|
||||
std::size_t GetCharacterPosition(const std::string_view& str, std::size_t characterIndex)
|
||||
std::size_t GetCharacterPosition(std::string_view str, std::size_t characterIndex)
|
||||
{
|
||||
const char* ptr = str.data();
|
||||
const char* end = ptr + str.size();
|
||||
@@ -212,7 +212,7 @@ namespace Nz
|
||||
return std::string::npos;
|
||||
}
|
||||
|
||||
std::string_view GetWord(const std::string_view& str, std::size_t wordIndex)
|
||||
std::string_view GetWord(std::string_view str, std::size_t wordIndex)
|
||||
{
|
||||
std::size_t pos = 0;
|
||||
std::size_t previousPos = 0;
|
||||
@@ -228,7 +228,7 @@ namespace Nz
|
||||
return {};
|
||||
}
|
||||
|
||||
std::string_view GetWord(const std::string_view& str, std::size_t wordIndex, UnicodeAware)
|
||||
std::string_view GetWord(std::string_view str, std::size_t wordIndex, UnicodeAware)
|
||||
{
|
||||
NAZARA_USE_ANONYMOUS_NAMESPACE
|
||||
|
||||
@@ -259,7 +259,7 @@ namespace Nz
|
||||
return {};
|
||||
}
|
||||
|
||||
bool MatchPattern(const std::string_view& str, const std::string_view& pattern)
|
||||
bool MatchPattern(std::string_view str, std::string_view pattern)
|
||||
{
|
||||
if (str.empty() || pattern.empty())
|
||||
return false;
|
||||
@@ -321,7 +321,7 @@ namespace Nz
|
||||
return str;
|
||||
}
|
||||
|
||||
bool StartsWith(const std::string_view& lhs, const std::string_view& rhs, CaseIndependent)
|
||||
bool StartsWith(std::string_view lhs, std::string_view rhs, CaseIndependent)
|
||||
{
|
||||
NAZARA_USE_ANONYMOUS_NAMESPACE
|
||||
|
||||
@@ -334,7 +334,7 @@ namespace Nz
|
||||
});
|
||||
}
|
||||
|
||||
bool StartsWith(const std::string_view& lhs, const std::string_view& rhs, UnicodeAware)
|
||||
bool StartsWith(std::string_view lhs, std::string_view rhs, UnicodeAware)
|
||||
{
|
||||
if (lhs.empty())
|
||||
return lhs == rhs;
|
||||
@@ -358,7 +358,7 @@ namespace Nz
|
||||
return true;
|
||||
}
|
||||
|
||||
bool StartsWith(const std::string_view& lhs, const std::string_view& rhs, CaseIndependent, UnicodeAware)
|
||||
bool StartsWith(std::string_view lhs, std::string_view rhs, CaseIndependent, UnicodeAware)
|
||||
{
|
||||
if (lhs.empty())
|
||||
return lhs == rhs;
|
||||
@@ -382,7 +382,7 @@ namespace Nz
|
||||
return true;
|
||||
}
|
||||
|
||||
bool StringEqual(const std::string_view& lhs, const std::string_view& rhs, UnicodeAware)
|
||||
bool StringEqual(std::string_view lhs, std::string_view rhs, UnicodeAware)
|
||||
{
|
||||
if (lhs.empty() || rhs.empty())
|
||||
return lhs == rhs;
|
||||
@@ -399,7 +399,7 @@ namespace Nz
|
||||
return true;
|
||||
}
|
||||
|
||||
bool StringEqual(const std::string_view& lhs, const std::string_view& rhs, CaseIndependent, UnicodeAware)
|
||||
bool StringEqual(std::string_view lhs, std::string_view rhs, CaseIndependent, UnicodeAware)
|
||||
{
|
||||
if (lhs.empty() || rhs.empty())
|
||||
return lhs == rhs;
|
||||
@@ -416,7 +416,7 @@ namespace Nz
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string ToLower(const std::string_view& str)
|
||||
std::string ToLower(std::string_view str)
|
||||
{
|
||||
NAZARA_USE_ANONYMOUS_NAMESPACE
|
||||
|
||||
@@ -427,7 +427,7 @@ namespace Nz
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string ToLower(const std::string_view& str, UnicodeAware)
|
||||
std::string ToLower(std::string_view str, UnicodeAware)
|
||||
{
|
||||
if (str.empty())
|
||||
return std::string();
|
||||
@@ -443,7 +443,7 @@ namespace Nz
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string ToUpper(const std::string_view& str)
|
||||
std::string ToUpper(std::string_view str)
|
||||
{
|
||||
NAZARA_USE_ANONYMOUS_NAMESPACE
|
||||
|
||||
@@ -454,7 +454,7 @@ namespace Nz
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string ToUpper(const std::string_view& str, UnicodeAware)
|
||||
std::string ToUpper(std::string_view str, UnicodeAware)
|
||||
{
|
||||
if (str.empty())
|
||||
return std::string();
|
||||
@@ -470,7 +470,7 @@ namespace Nz
|
||||
return result;
|
||||
}
|
||||
|
||||
std::u16string ToUtf16String(const std::string_view& str)
|
||||
std::u16string ToUtf16String(std::string_view str)
|
||||
{
|
||||
std::u16string result;
|
||||
utf8::utf8to16(str.begin(), str.end(), std::back_inserter(result));
|
||||
@@ -478,7 +478,7 @@ namespace Nz
|
||||
return result;
|
||||
}
|
||||
|
||||
std::u32string ToUtf32String(const std::string_view& str)
|
||||
std::u32string ToUtf32String(std::string_view str)
|
||||
{
|
||||
std::u32string result;
|
||||
utf8::utf8to32(str.begin(), str.end(), std::back_inserter(result));
|
||||
@@ -486,7 +486,7 @@ namespace Nz
|
||||
return result;
|
||||
}
|
||||
|
||||
std::wstring ToWideString(const std::string_view& str)
|
||||
std::wstring ToWideString(std::string_view str)
|
||||
{
|
||||
NAZARA_USE_ANONYMOUS_NAMESPACE
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
void OpenGLCommandBufferBuilder::BeginDebugRegion(const std::string_view& regionName, const Color& color)
|
||||
void OpenGLCommandBufferBuilder::BeginDebugRegion(std::string_view regionName, const Color& color)
|
||||
{
|
||||
m_commandBuffer.BeginDebugRegion(regionName, color);
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ namespace Nz
|
||||
env.glES = (contextParams.type == GL::ContextType::OpenGL_ES);
|
||||
env.glMajorVersion = contextParams.glMajorVersion;
|
||||
env.glMinorVersion = contextParams.glMinorVersion;
|
||||
env.extCallback = [&](const std::string_view& ext)
|
||||
env.extCallback = [&](std::string_view ext)
|
||||
{
|
||||
return context.IsExtensionSupported(std::string(ext));
|
||||
};
|
||||
|
||||
@@ -1027,7 +1027,7 @@ namespace Nz::GL
|
||||
m_vaoCache.Clear();
|
||||
}
|
||||
|
||||
bool Context::ImplementFallback(const std::string_view& function)
|
||||
bool Context::ImplementFallback(std::string_view function)
|
||||
{
|
||||
SymbolLoader loader(*this);
|
||||
|
||||
|
||||
@@ -296,7 +296,7 @@ namespace Nz::GL
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EGLContextBase::ImplementFallback(const std::string_view& function)
|
||||
bool EGLContextBase::ImplementFallback(std::string_view function)
|
||||
{
|
||||
if (Context::ImplementFallback(function))
|
||||
return true;
|
||||
|
||||
@@ -245,7 +245,7 @@ namespace Nz::GL
|
||||
}
|
||||
}
|
||||
|
||||
bool EGLLoader::ImplementFallback(const std::string_view& /*function*/)
|
||||
bool EGLLoader::ImplementFallback(std::string_view /*function*/)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -238,7 +238,7 @@ namespace Nz::GL
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WGLContext::ImplementFallback(const std::string_view& function)
|
||||
bool WGLContext::ImplementFallback(std::string_view function)
|
||||
{
|
||||
if (Context::ImplementFallback(function))
|
||||
return true;
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Nz
|
||||
DDSLoader() = delete;
|
||||
~DDSLoader() = delete;
|
||||
|
||||
static bool IsSupported(const std::string_view& extension)
|
||||
static bool IsSupported(std::string_view extension)
|
||||
{
|
||||
return (extension == ".dds");
|
||||
}
|
||||
|
||||
@@ -378,7 +378,7 @@ namespace Nz
|
||||
mutable unsigned int m_characterSize;
|
||||
};
|
||||
|
||||
bool IsFreetypeSupported(const std::string_view& extension)
|
||||
bool IsFreetypeSupported(std::string_view extension)
|
||||
{
|
||||
constexpr auto s_supportedExtensions = frozen::make_unordered_set<frozen::string>({ ".afm", ".bdf", ".cff", ".cid", ".dfont", ".fnt", ".fon", ".otf", ".pfa", ".pfb", ".pfm", ".pfr", ".sfnt", ".ttc", ".tte", ".ttf" });
|
||||
|
||||
|
||||
@@ -704,7 +704,7 @@ namespace Nz
|
||||
bool m_requiresFrameHistory;
|
||||
};
|
||||
|
||||
bool CheckGIFExtension(const std::string_view& extension)
|
||||
bool CheckGIFExtension(std::string_view extension)
|
||||
{
|
||||
return extension == ".gif";
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace Nz
|
||||
{
|
||||
namespace
|
||||
{
|
||||
bool IsMD2Supported(const std::string_view& extension)
|
||||
bool IsMD2Supported(std::string_view extension)
|
||||
{
|
||||
return (extension == ".md2");
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace Nz
|
||||
{
|
||||
namespace
|
||||
{
|
||||
bool IsMD5AnimSupported(const std::string_view& extension)
|
||||
bool IsMD5AnimSupported(std::string_view extension)
|
||||
{
|
||||
return extension == ".md5anim";
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace Nz
|
||||
{
|
||||
namespace
|
||||
{
|
||||
bool IsMD5MeshSupported(const std::string_view& extension)
|
||||
bool IsMD5MeshSupported(std::string_view extension)
|
||||
{
|
||||
return (extension == ".md5mesh");
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace Nz
|
||||
{
|
||||
namespace
|
||||
{
|
||||
bool IsOBJSupported(const std::string_view& extension)
|
||||
bool IsOBJSupported(std::string_view extension)
|
||||
{
|
||||
return (extension == ".obj");
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace Nz
|
||||
T* m_buffer;
|
||||
};
|
||||
|
||||
bool IsOBJSupportedSave(const std::string_view& extension)
|
||||
bool IsOBJSupportedSave(std::string_view extension)
|
||||
{
|
||||
return (extension == ".obj");
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace Nz
|
||||
|
||||
static_assert(sizeof(PCXHeader) == (6+48+54)*sizeof(UInt8) + 10*sizeof(UInt16), "pcx_header struct must be packed");
|
||||
|
||||
bool IsPCXSupported(const std::string_view& extension)
|
||||
bool IsPCXSupported(std::string_view extension)
|
||||
{
|
||||
return (extension == ".pcx");
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace Nz
|
||||
|
||||
static stbi_io_callbacks s_stbiCallbacks = { StbiRead, StbiSkip, StbiEof };
|
||||
|
||||
bool IsSTBSupported(const std::string_view& extension)
|
||||
bool IsSTBSupported(std::string_view extension)
|
||||
{
|
||||
constexpr auto s_supportedExtensions = frozen::make_unordered_set<frozen::string>({ ".bmp", ".gif", ".hdr", ".jpg", ".jpeg", ".pic", ".png", ".ppm", ".pgm", ".psd", ".tga" });
|
||||
|
||||
|
||||
@@ -230,7 +230,7 @@ namespace Nz
|
||||
{ ".tga", &SaveTGA }
|
||||
});
|
||||
|
||||
bool FormatQuerier(const std::string_view& extension)
|
||||
bool FormatQuerier(std::string_view extension)
|
||||
{
|
||||
return s_formatHandlers.find(extension) != s_formatHandlers.end();
|
||||
}
|
||||
|
||||
@@ -182,7 +182,7 @@ namespace Nz
|
||||
return false;
|
||||
};
|
||||
|
||||
void SimpleTextDrawer::GenerateGlyphs(const std::string_view& text) const
|
||||
void SimpleTextDrawer::GenerateGlyphs(std::string_view text) const
|
||||
{
|
||||
if (text.empty())
|
||||
return;
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
void VulkanCommandBufferBuilder::BeginDebugRegion(const std::string_view& regionName, const Color& color)
|
||||
void VulkanCommandBufferBuilder::BeginDebugRegion(std::string_view regionName, const Color& color)
|
||||
{
|
||||
// Ensure \0 at the end of string
|
||||
StackArray<char> regionNameEOS = NazaraStackArrayNoInit(char, regionName.size() + 1);
|
||||
|
||||
Reference in New Issue
Block a user