common/MessageQueue.cpp | 10 +++++----- test/helpers.hpp | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-)
New commits: commit a8f3263132bee4b59bb9f72fdb54113751193bbe Author: Ashod Nakashian <[email protected]> Date: Sat Nov 26 22:24:35 2016 -0500 loolwsd: use more efficient matchPrefix Change-Id: I6f34b314295335270ff4da2827517d818c6a62ab Reviewed-on: https://gerrit.libreoffice.org/31285 Reviewed-by: Ashod Nakashian <[email protected]> Tested-by: Ashod Nakashian <[email protected]> diff --git a/common/MessageQueue.cpp b/common/MessageQueue.cpp index b32fdeb..12a2abb 100644 --- a/common/MessageQueue.cpp +++ b/common/MessageQueue.cpp @@ -152,7 +152,7 @@ void TileQueue::put_impl(const Payload& value) void TileQueue::removeDuplicate(const std::string& tileMsg) { - assert(LOOLProtocol::getFirstToken(tileMsg) == "tile"); + assert(LOOLProtocol::matchPrefix("tile", tileMsg, /*ignoreWhitespace*/ true)); // Ver is always provided at this point and it is necessary to // return back to clients the last rendered version of a tile @@ -200,7 +200,7 @@ void TileQueue::deprioritizePreviews() // stop at the first non-tile or non-'id' (preview) message std::string id; - if (LOOLProtocol::getFirstToken(message) != "tile" || + if (!LOOLProtocol::matchPrefix("tile", message) || !LOOLProtocol::getTokenStringFromMessage(message, "id", id)) { break; @@ -218,7 +218,7 @@ MessageQueue::Payload TileQueue::get_impl() auto msg = std::string(front.data(), front.size()); std::string id; - bool isTile = (LOOLProtocol::getFirstToken(msg) == "tile"); + bool isTile = LOOLProtocol::matchPrefix("tile", msg); bool isPreview = isTile && LOOLProtocol::getTokenStringFromMessage(msg, "id", id); if (!isTile || isPreview) { @@ -246,7 +246,7 @@ MessageQueue::Payload TileQueue::get_impl() // avoid starving - stop the search when we reach a non-tile, // otherwise we may keep growing the queue of unhandled stuff (both // tiles and non-tiles) - if (LOOLProtocol::getFirstToken(prio) != "tile" || + if (!LOOLProtocol::matchPrefix("tile", prio) || LOOLProtocol::getTokenStringFromMessage(prio, "id", id)) { break; @@ -277,7 +277,7 @@ MessageQueue::Payload TileQueue::get_impl() { auto& it = _queue[i]; msg = std::string(it.data(), it.size()); - if (LOOLProtocol::getFirstToken(msg) != "tile" || + if (!LOOLProtocol::matchPrefix("tile", msg) || LOOLProtocol::getTokenStringFromMessage(msg, "id", id)) { // Don't combine non-tiles or tiles with id. diff --git a/test/helpers.hpp b/test/helpers.hpp index a10cc53..b33dcb4 100644 --- a/test/helpers.hpp +++ b/test/helpers.hpp @@ -324,7 +324,7 @@ bool isDocumentLoaded(LOOLWebSocket& ws, const std::string& name = "", bool isVi { const std::string prefix = isView ? "status:" : "statusindicatorfinish:"; const auto message = getResponseString(ws, prefix, name); - return LOOLProtocol::getFirstToken(message) == prefix; + return LOOLProtocol::matchPrefix(prefix, message); } inline _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
