Optimize parameter passing to avoid unnecessary copying

This commit is contained in:
Pugemon
2024-06-07 04:00:38 +03:00
parent 46ca1bb04a
commit f25a425cb9
123 changed files with 578 additions and 522 deletions
+3 -3
View File
@@ -128,7 +128,7 @@ extern uint32_t util::decode_utf8(uint& size, const char* chr) {
return code;
}
std::string util::wstr2str_utf8(const std::wstring ws) {
std::string util::wstr2str_utf8(const std::wstring& ws) {
std::vector<char> chars;
char buffer[4];
for (wchar_t wc : ws) {
@@ -140,7 +140,7 @@ std::string util::wstr2str_utf8(const std::wstring ws) {
return std::string(chars.data(), chars.size());
}
std::wstring util::str2wstr_utf8(const std::string s) {
std::wstring util::str2wstr_utf8(const std::string& s) {
std::vector<wchar_t> chars;
size_t pos = 0;
uint size = 0;
@@ -167,7 +167,7 @@ bool util::is_integer(const std::wstring& text) {
return true;
}
bool util::is_valid_filename(std::wstring name) {
bool util::is_valid_filename(const std::wstring& name) {
for (wchar_t c : name) {
if (c < 31 || c == '/' || c == '\\' || c == '<' || c == '>' ||
c == ':' || c == '"' || c == '|' || c == '?' || c == '*'){