From feb36a4a05ada6c61d946f16741876c5101ba5bc Mon Sep 17 00:00:00 2001 From: Ashod Nakashian Date: Sun, 21 Oct 2018 16:09:24 -0400 Subject: [PATCH] wsd: hoist token parsing outside lock and optimize Change-Id: I8710f0c3040d22588b46bec732cf8bca7c503244 --- kit/ChildSession.cpp | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/kit/ChildSession.cpp b/kit/ChildSession.cpp index d30bfb5a9..0d779de88 100644 --- a/kit/ChildSession.cpp +++ b/kit/ChildSession.cpp @@ -1222,16 +1222,11 @@ bool ChildSession::selectText(const char* /*buffer*/, int /*length*/, const std: bool ChildSession::renderWindow(const char* /*buffer*/, int /*length*/, const std::vector& tokens) { + const unsigned winId = (tokens.size() > 1 ? std::stoul(tokens[1]) : 0); + std::unique_lock lock(_docManager.getDocumentMutex()); getLOKitDocument()->setView(_viewId); - unsigned winId = 0; - if (tokens.size() > 1) - { - std::istringstream reader(tokens[1]); - reader >> winId; - } - int startX = 0, startY = 0; int bufferWidth = 800, bufferHeight = 600; double dpiScale = 1.0; @@ -1298,18 +1293,11 @@ bool ChildSession::renderWindow(const char* /*buffer*/, int /*length*/, const st bool ChildSession::sendWindowCommand(const char* /*buffer*/, int /*length*/, const std::vector& tokens) { + const unsigned winId = (tokens.size() > 1 ? std::stoul(tokens[1]) : 0); + std::unique_lock lock(_docManager.getDocumentMutex()); getLOKitDocument()->setView(_viewId); - unsigned winId = 0; - if (tokens.size() > 1) - { - std::istringstream reader(tokens[1]); - reader >> winId; - } - - getLOKitDocument()->setView(_viewId); - if (tokens.size() > 2 && tokens[2] == "close") getLOKitDocument()->postWindow(winId, LOK_WINDOW_CLOSE);