wsd: hoist token parsing outside lock and optimize

Change-Id: I8710f0c3040d22588b46bec732cf8bca7c503244
This commit is contained in:
Ashod Nakashian 2018-10-21 16:09:24 -04:00 committed by Jan Holesovsky
parent d7758373fe
commit feb36a4a05

View file

@ -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<std::string>& tokens)
{
const unsigned winId = (tokens.size() > 1 ? std::stoul(tokens[1]) : 0);
std::unique_lock<std::mutex> 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<std::string>& tokens)
{
const unsigned winId = (tokens.size() > 1 ? std::stoul(tokens[1]) : 0);
std::unique_lock<std::mutex> 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);