From db287b2bc64da2a57bd09c4146837c31ebe248b9 Mon Sep 17 00:00:00 2001 From: Kindi Date: Fri, 1 Sep 2023 19:33:25 +0800 Subject: [PATCH] dont use pass by const reference for small types in func arguments --- components/lua/utf8.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/components/lua/utf8.cpp b/components/lua/utf8.cpp index 125b33fbe1..d3927212b4 100644 --- a/components/lua/utf8.cpp +++ b/components/lua/utf8.cpp @@ -7,14 +7,14 @@ namespace { constexpr std::string_view UTF8PATT = "[%z\x01-\x7F\xC2-\xF4][\x80-\xBF]*"; // %z is deprecated in Lua5.2 constexpr uint32_t MAXUTF = 0x7FFFFFFFu; - constexpr uint32_t MAXUNICODE = 0x10FFFFu; + //constexpr uint32_t MAXUNICODE = 0x10FFFFu; inline bool isNilOrNone(const sol::stack_proxy arg) { return (arg.get_type() == sol::type::lua_nil || arg.get_type() == sol::type::none); } - inline double getInteger(const sol::stack_proxy arg, const size_t& n, const std::string_view& name) + inline double getInteger(const sol::stack_proxy arg, const size_t n, const std::string_view name) { double integer; if (!arg.is()) @@ -28,14 +28,14 @@ namespace return integer; } - inline void relativePosition(int64_t& pos, const size_t& len) + inline void relativePosition(int64_t& pos, const size_t len) { if (pos < 0) pos = std::max(0, pos + len + 1); } // returns: first - character pos in bytes, second - character codepoint - std::pair decodeNextUTF8Character(const std::string_view& s, std::vector& pos_byte) + std::pair decodeNextUTF8Character(const std::string_view s, std::vector& pos_byte) { const int64_t pos = pos_byte.back() - 1; const unsigned char ch = static_cast(s[pos]); @@ -123,7 +123,7 @@ namespace LuaUtf8 utf8["len"] = [](const std::string_view& s, const sol::variadic_args args) -> std::variant> { - size_t len = s.size(); + const size_t len = s.size(); int64_t iv = isNilOrNone(args[0]) ? 1 : getInteger(args[0], 2, "len"); int64_t fv = isNilOrNone(args[1]) ? -1 : getInteger(args[1], 3, "len");