From 92c2a7756dd33775c787c840947aa5df5c79f599 Mon Sep 17 00:00:00 2001 From: Benjamin Sergeant Date: Sun, 23 Jun 2019 14:32:17 -0700 Subject: [PATCH] rewrite http::trim in a simple way --- ixwebsocket/IXHttp.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/ixwebsocket/IXHttp.cpp b/ixwebsocket/IXHttp.cpp index c94049b3..d2aa5f64 100644 --- a/ixwebsocket/IXHttp.cpp +++ b/ixwebsocket/IXHttp.cpp @@ -15,10 +15,15 @@ namespace ix { std::string Http::trim(const std::string& str) { - std::string out(str); - out.erase(std::remove(out.begin(), out.end(), ' '), out.end()); - out.erase(std::remove(out.begin(), out.end(), '\r'), out.end()); - out.erase(std::remove(out.begin(), out.end(), '\n'), out.end()); + std::string out; + for (auto c : str) + { + if (c != ' ' && c != '\n' && c != '\r') + { + out += c; + } + } + return out; }