diff --git a/mac/util.cpp b/mac/util.cpp index 5e2acc4..15f1065 100644 --- a/mac/util.cpp +++ b/mac/util.cpp @@ -229,7 +229,10 @@ std::string join(int argc, char* argv[], const std::string& separator) { std::string result {}; for (int i = 0; i < argc; ++i) { - result += std::string(argv[i]) + separator; + // Append directly (see argv_to_string): avoids a temporary and the same + // GCC 12 -Wrestrict false positive. + result += argv[i]; + result += separator; } return result; } @@ -241,7 +244,11 @@ std::string argv_to_string(int argc, char* argv[]) } std::string result = argv[0]; for (int i = 1; i < argc; ++i) { - result += " " + std::string(argv[i]); + // Append the pieces directly rather than building a `" " + string(...)` + // temporary: identical result, avoids an allocation, and sidesteps a + // GCC 12 -Wrestrict false positive on the temporary's memcpy. + result += ' '; + result += argv[i]; } return result; }