diff options
author | Ashod Nakashian <ashod.nakashian@collabora.co.uk> | 2016-11-20 16:16:13 -0500 |
---|---|---|
committer | Ashod Nakashian <ashnakash@gmail.com> | 2016-11-28 04:50:57 +0000 |
commit | 86b38a29de0808305c928b7261463b542bcd86be (patch) | |
tree | f67dd3fe2fd910eb6709e3726bd219f3fea79fd0 /common/Protocol.cpp | |
parent | .gitignore editor dot files (diff) | |
download | online-86b38a29de0808305c928b7261463b542bcd86be.tar.gz online-86b38a29de0808305c928b7261463b542bcd86be.zip |
loolwsd: fast in-place getTokenStringFromMessage
Change-Id: I5a7a7402c9394ac72aca907fc8b1072f6d2df5ad
Reviewed-on: https://gerrit.libreoffice.org/31284
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
Diffstat (limited to 'common/Protocol.cpp')
-rw-r--r-- | common/Protocol.cpp | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/common/Protocol.cpp b/common/Protocol.cpp index 6cd5455ce3..ad02f0fd18 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) |