From 74a3e0eddf360534a028b29d7076cf65212b940b Mon Sep 17 00:00:00 2001 From: George Murray Date: Thu, 24 Sep 2020 15:22:58 -0700 Subject: [PATCH] Use a string and .reserve for normalizing instead of stringbuf --- library/MiscUtils.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/library/MiscUtils.cpp b/library/MiscUtils.cpp index 2659d5d43..56af85afe 100644 --- a/library/MiscUtils.cpp +++ b/library/MiscUtils.cpp @@ -150,21 +150,22 @@ static const char *normalized_table[256] = { std::string to_search_normalized(const std::string &str) { - std::stringbuf result; + std::string result; + result.reserve(str.size()); for (char c : str) { const char *mapped = normalized_table[(uint8_t)c]; if (mapped == NULL) - result.sputc(tolower(c)); + result += tolower(c); else while (*mapped != '\0') { - result.sputc(tolower(*mapped)); + result += tolower(*mapped); ++mapped; } } - return result.str(); + return result; } bool word_wrap(std::vector *out, const std::string &str, size_t line_length)