common/MessageQueue.cpp | 7 ++----- common/Session.cpp | 1 - kit/ChildSession.cpp | 8 +++----- kit/Kit.cpp | 14 ++++++-------- wsd/ClientSession.cpp | 14 ++++++-------- 5 files changed, 17 insertions(+), 27 deletions(-)
New commits: commit efa293290cf7ab3520e4d72552aeecf68ffde2ce Author: Jan Holesovsky <ke...@collabora.com> AuthorDate: Fri Nov 8 15:05:19 2019 +0100 Commit: Jan Holesovsky <ke...@collabora.com> CommitDate: Fri Nov 8 22:21:31 2019 +0100 killpoco: Remove trivial StringTokenizer uses from some files. Particularly those used on Android... Change-Id: I47bf9692f5e99ba30140d698558472201168a198 Reviewed-on: https://gerrit.libreoffice.org/82302 Reviewed-by: Jan Holesovsky <ke...@collabora.com> Tested-by: Jan Holesovsky <ke...@collabora.com> diff --git a/common/MessageQueue.cpp b/common/MessageQueue.cpp index ce639e3f1..dd8ea33b3 100644 --- a/common/MessageQueue.cpp +++ b/common/MessageQueue.cpp @@ -16,14 +16,11 @@ #include <Poco/JSON/JSON.h> #include <Poco/JSON/Object.h> #include <Poco/JSON/Parser.h> -#include <Poco/StringTokenizer.h> #include "Protocol.hpp" #include "Log.hpp" #include <TileDesc.hpp> -using Poco::StringTokenizer; - void TileQueue::put_impl(const Payload& value) { const std::string msg = std::string(value.data(), value.size()); @@ -33,7 +30,7 @@ void TileQueue::put_impl(const Payload& value) { LOG_TRC("Processing [" << LOOLProtocol::getAbbreviatedMessage(msg) << "]. Before canceltiles have " << getQueue().size() << " in queue."); const std::string seqs = msg.substr(12); - StringTokenizer tokens(seqs, ",", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM); + std::vector<std::string> tokens(LOOLProtocol::tokenize(seqs, ',')); getQueue().erase(std::remove_if(getQueue().begin(), getQueue().end(), [&tokens](const Payload& v) { @@ -41,7 +38,7 @@ void TileQueue::put_impl(const Payload& value) // Tile is for a thumbnail, don't cancel it if (s.find("id=") != std::string::npos) return false; - for (size_t i = 0; i < tokens.count(); ++i) + for (size_t i = 0; i < tokens.size(); ++i) { if (s.find("ver=" + tokens[i]) != std::string::npos) { diff --git a/common/Session.cpp b/common/Session.cpp index 43db40908..9495cc99a 100644 --- a/common/Session.cpp +++ b/common/Session.cpp @@ -29,7 +29,6 @@ #include <Poco/Exception.h> #include <Poco/Path.h> #include <Poco/String.h> -#include <Poco/StringTokenizer.h> #include <Poco/URI.h> #include "Common.hpp" diff --git a/kit/ChildSession.cpp b/kit/ChildSession.cpp index c2fc39a77..98101b6b1 100644 --- a/kit/ChildSession.cpp +++ b/kit/ChildSession.cpp @@ -20,7 +20,6 @@ #include <Poco/JSON/Object.h> #include <Poco/JSON/Parser.h> #include <Poco/Net/WebSocket.h> -#include <Poco/StringTokenizer.h> #include <Poco/StreamCopier.h> #include <Poco/URI.h> #include <Poco/BinaryReader.h> @@ -46,7 +45,6 @@ using Poco::JSON::Object; using Poco::JSON::Parser; -using Poco::StringTokenizer; using Poco::URI; using namespace LOOLProtocol; @@ -2270,8 +2268,8 @@ void ChildSession::loKitCallback(const int type, const std::string& payload) { case LOK_CALLBACK_INVALIDATE_TILES: { - StringTokenizer tokens(payload, ",", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM); - if (tokens.count() == 5) + std::vector<std::string> tokens(LOOLProtocol::tokenize(payload, ',')); + if (tokens.size() == 5) { int part, x, y, width, height; try @@ -2300,7 +2298,7 @@ void ChildSession::loKitCallback(const int type, const std::string& payload) " width=" + std::to_string(width) + " height=" + std::to_string(height)); } - else if (tokens.count() == 2 && tokens[0] == "EMPTY") + else if (tokens.size() == 2 && tokens[0] == "EMPTY") { const std::string part = (_docType != "text" ? tokens[1].c_str() : "0"); // Writer renders everything as part 0. sendTextFrame("invalidatetiles: EMPTY, " + part); diff --git a/kit/Kit.cpp b/kit/Kit.cpp index 4a152ef91..d04277bf8 100644 --- a/kit/Kit.cpp +++ b/kit/Kit.cpp @@ -50,7 +50,6 @@ #include <Poco/Net/Socket.h> #include <Poco/Process.h> #include <Poco/Runnable.h> -#include <Poco/StringTokenizer.h> #include <Poco/URI.h> #include "ChildSession.hpp" @@ -95,7 +94,6 @@ using Poco::File; using Poco::JSON::Array; using Poco::JSON::Object; using Poco::JSON::Parser; -using Poco::StringTokenizer; using Poco::URI; #ifndef BUILDING_TESTS @@ -1225,9 +1223,9 @@ public: if (type == LOK_CALLBACK_CELL_CURSOR) { - Poco::StringTokenizer tokens(payload, ",", Poco::StringTokenizer::TOK_IGNORE_EMPTY | Poco::StringTokenizer::TOK_TRIM); + std::vector<std::string> tokens(LOOLProtocol::tokenize(payload, ',')); // Payload may be 'EMPTY'. - if (tokens.count() == 4) + if (tokens.size() == 4) { int cursorX = std::stoi(tokens[0]); int cursorY = std::stoi(tokens[1]); @@ -1243,9 +1241,9 @@ public: const Poco::Dynamic::Var result = parser.parse(payload); const auto& command = result.extract<Poco::JSON::Object::Ptr>(); std::string rectangle = command->get("rectangle").toString(); - Poco::StringTokenizer tokens(rectangle, ",", Poco::StringTokenizer::TOK_IGNORE_EMPTY | Poco::StringTokenizer::TOK_TRIM); + std::vector<std::string> tokens(LOOLProtocol::tokenize(rectangle, ',')); // Payload may be 'EMPTY'. - if (tokens.count() == 4) + if (tokens.size() == 4) { int cursorX = std::stoi(tokens[0]); int cursorY = std::stoi(tokens[1]); @@ -1264,9 +1262,9 @@ public: targetViewId = command->get("viewId").toString(); std::string part = command->get("part").toString(); std::string text = command->get("rectangle").toString(); - Poco::StringTokenizer tokens(text, ",", Poco::StringTokenizer::TOK_IGNORE_EMPTY | Poco::StringTokenizer::TOK_TRIM); + std::vector<std::string> tokens(LOOLProtocol::tokenize(text, ',')); // Payload may be 'EMPTY'. - if (tokens.count() == 4) + if (tokens.size() == 4) { int cursorX = std::stoi(tokens[0]); int cursorY = std::stoi(tokens[1]); diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp index c2ca93237..5e3b23547 100644 --- a/wsd/ClientSession.cpp +++ b/wsd/ClientSession.cpp @@ -18,7 +18,6 @@ #include <Poco/Net/HTTPResponse.h> #include <Poco/StreamCopier.h> -#include <Poco/StringTokenizer.h> #include <Poco/URI.h> #include "DocumentBroker.hpp" @@ -35,7 +34,6 @@ using namespace LOOLProtocol; using Poco::Path; -using Poco::StringTokenizer; static std::mutex SessionMapMutex; static std::unordered_map<std::string, std::weak_ptr<ClientSession>> SessionMap; @@ -898,7 +896,7 @@ bool ClientSession::forwardToChild(const std::string& message, bool ClientSession::filterMessage(const std::string& message) const { bool allowed = true; - StringTokenizer tokens(message, " ", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM); + std::vector<std::string> tokens(LOOLProtocol::tokenize(message, ' ')); // Set allowed flag to false depending on if particular WOPI properties are set if (tokens[0] == "downloadas") @@ -1246,8 +1244,8 @@ bool ClientSession::handleKitToClientMessage(const char* buffer, const int lengt #endif else if (tokens.size() == 2 && tokens[0] == "statechanged:") { - StringTokenizer stateTokens(tokens[1], "=", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM); - if (stateTokens.count() == 2 && stateTokens[0] == ".uno:ModifiedStatus") + std::vector<std::string> stateTokens(LOOLProtocol::tokenize(tokens[1], '=')); + if (stateTokens.size() == 2 && stateTokens[0] == ".uno:ModifiedStatus") { docBroker->setModified(stateTokens[1] == "true"); } @@ -1430,13 +1428,13 @@ bool ClientSession::handleKitToClientMessage(const char* buffer, const int lengt const Poco::Dynamic::Var result = parser.parse(stringJSON); const auto& object = result.extract<Poco::JSON::Object::Ptr>(); const std::string rectangle = object->get("rectangle").toString(); - StringTokenizer rectangleTokens(rectangle, ",", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM); + std::vector<std::string> rectangleTokens(LOOLProtocol::tokenize(rectangle, ',')); int x = 0, y = 0, w = 0, h = 0; - if (rectangleTokens.count() > 2 && + if (rectangleTokens.size() > 2 && stringToInteger(rectangleTokens[0], x) && stringToInteger(rectangleTokens[1], y)) { - if (rectangleTokens.count() > 3) + if (rectangleTokens.size() > 3) { stringToInteger(rectangleTokens[2], w); stringToInteger(rectangleTokens[3], h); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits