common/Protocol.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-)
New commits: commit 86b38a29de0808305c928b7261463b542bcd86be Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk> Date: Sun Nov 20 16:16:13 2016 -0500 loolwsd: fast in-place getTokenStringFromMessage Change-Id: I5a7a7402c9394ac72aca907fc8b1072f6d2df5ad Reviewed-on: https://gerrit.libreoffice.org/31284 Reviewed-by: Ashod Nakashian <ashnak...@gmail.com> Tested-by: Ashod Nakashian <ashnak...@gmail.com> diff --git a/common/Protocol.cpp b/common/Protocol.cpp index 6cd5455..ad02f0f 100644 --- a/common/Protocol.cpp +++ b/common/Protocol.cpp @@ -157,8 +157,24 @@ namespace LOOLProtocol bool getTokenStringFromMessage(const std::string& message, const std::string& name, std::string& value) { - Poco::StringTokenizer tokens(message, " \n", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM); - return getTokenString(tokens, name, value); + if (message.size() > name.size() + 1) + { + auto pos = message.find(name); + while (pos != std::string::npos) + { + const auto beg = pos + name.size(); + if (message[beg] == '=') + { + const auto end = message.find_first_of(" \n", beg); + value = message.substr(beg + 1, end - beg - 1); + return true; + } + + pos = message.find(name, pos + name.size()); + } + } + + return false; } bool getTokenKeywordFromMessage(const std::string& message, const std::string& name, const std::map<std::string, int>& map, int& value) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits