From ddf2f122a2e2296276b53fec5fd0519c6be64a99 Mon Sep 17 00:00:00 2001 From: Tomas Babej Date: Sat, 28 Aug 2021 10:26:17 -0400 Subject: [PATCH] CLI2: Pre-reserve the size of the escaped string --- src/CLI2.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/CLI2.cpp b/src/CLI2.cpp index ae50e0400..8866179ee 100644 --- a/src/CLI2.cpp +++ b/src/CLI2.cpp @@ -422,10 +422,12 @@ void CLI2::lexArguments () // Escape unescaped single quotes std::string escaped = ""; + + // For performance reasons. The escaped string is as long as the original. + escaped.reserve (_original_args[i].attribute ("raw").size ()); + std::string::size_type cursor = 0; - bool nextEscaped = false; - while (int num = utf8_next_char (_original_args[i].attribute ("raw"), cursor)) { std::string character = utf8_character (num);