diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2020-02-28 14:51:22 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2020-02-28 18:31:37 +0100 |
commit | 547f9ea73186d274d512a9fa1f01e6edcad66bab (patch) | |
tree | 50ccbbcd9c7ae0e0d4fc6da93a667aa05c5cfbdc /kit/ChildSession.cpp | |
parent | b8bd1990aaa1b063ca21b78ffec629b5d5ae7697 (diff) |
Rework StringVector to have a single underlying string
This is meant to reduce lots of small allocations and instead have
pointers into the single string for the various tokens instead.
This has a few requirements, though:
1) It's no longer OK to modify the tokens, changing their length would
invalidate the start/length of other tokens. Rework
DocumentBroker::load() to avoid such mutation.
2) The iterators no longer expose zero-terminated strings, so
Poco::cat() doesn't work anymore: add an own cat() instead and use that
in e.g. ChildSession. The own cat() has the benefit that it won't read
past the end of the array if the begin index is out of bounds to add
more safety.
(This nicely works towards killing Poco usage in general.)
3) If zero-terminated strings for all individual tokens is needed, a
copy has to be made, as done in spawnProcess().
(For all of these requirements, the build fails if there are problems.)
Change-Id: Iea40e4400e630b2d669f5c72aea85cb40edf9a2c
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/89711
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Diffstat (limited to 'kit/ChildSession.cpp')
-rw-r--r-- | kit/ChildSession.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/kit/ChildSession.cpp b/kit/ChildSession.cpp index 13bc1d8e4..3cd8642bd 100644 --- a/kit/ChildSession.cpp +++ b/kit/ChildSession.cpp @@ -365,10 +365,10 @@ bool ChildSession::_handleInput(const char *buffer, int length) if (tokens[1].find(".uno:SpellCheckApplySuggestion") != std::string::npos || tokens[1].find(".uno:LanguageStatus") != std::string::npos) { - std::vector<std::string> newTokens; + StringVector newTokens; newTokens.push_back(tokens[0]); newTokens.push_back(firstLine.substr(4)); // Copy the remaining part. - return unoCommand(buffer, length, StringVector(newTokens)); + return unoCommand(buffer, length, newTokens); } return unoCommand(buffer, length, tokens); } @@ -686,7 +686,7 @@ bool ChildSession::sendFontRendering(const char* /*buffer*/, int /*length*/, con return false; } - const std::string response = "renderfont: " + Poco::cat(std::string(" "), tokens.begin() + 1, tokens.end()) + "\n"; + const std::string response = "renderfont: " + tokens.cat(std::string(" "), 1) + "\n"; std::vector<char> output; output.resize(response.size()); @@ -903,7 +903,7 @@ bool ChildSession::downloadAs(const char* /*buffer*/, int /*length*/, const Stri { if (tokens.size() > 5) { - filterOptions += Poco::cat(std::string(" "), tokens.begin() + 5, tokens.end()); + filterOptions += tokens.cat(std::string(" "), 5); } } @@ -1413,7 +1413,7 @@ bool ChildSession::dialogEvent(const char* /*buffer*/, int /*length*/, const Str unsigned nLOKWindowId = std::stoi(tokens[1].c_str()); getLOKitDocument()->sendDialogEvent(nLOKWindowId, - Poco::cat(std::string(" "), tokens.begin() + 2, tokens.end()).c_str()); + tokens.cat(std::string(" "), 2).c_str()); return true; } @@ -1468,7 +1468,7 @@ bool ChildSession::unoCommand(const char* /*buffer*/, int /*length*/, const Stri else { getLOKitDocument()->postUnoCommand(tokens[1].c_str(), - Poco::cat(std::string(" "), tokens.begin() + 2, tokens.end()).c_str(), + tokens.cat(std::string(" "), 2).c_str(), bNotify); } @@ -2002,7 +2002,7 @@ bool ChildSession::saveAs(const char* /*buffer*/, int /*length*/, const StringVe { if (tokens.size() > 4) { - filterOptions += Poco::cat(std::string(" "), tokens.begin() + 4, tokens.end()); + filterOptions += tokens.cat(std::string(" "), 4); } } |