ChildSession::renderShapeSelection: vector -> unique_ptr

Open Writer, insert a multi-MP JPEG, select it.

Before:

ChildSession::renderShapeSelection: finished in 81.33 ms

After:

ChildSession::renderShapeSelection: finished in 74.67 ms (91.81% of baseline)

This is with an --enable-symbols core with a -O2 online, with libstdc++.

The cost on the Android profile with its libc++ looked even more,
spending time in the std::vector dtor.

Change-Id: I50af2e13fd24569dc32304420b8f3e70d15803eb
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/90262
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
This commit is contained in:
Miklos Vajna 2020-03-10 16:10:07 +01:00
parent 3e2daa3c1c
commit 893b7d880d

View file

@ -2181,13 +2181,14 @@ bool ChildSession::renderShapeSelection(const char* /*buffer*/, int /*length*/,
if (pOutput != nullptr && nOutputSize > 0)
{
static const std::string header = "shapeselectioncontent:\n";
std::vector<char> response(header.size() + nOutputSize);
std::memcpy(response.data(), header.data(), header.size());
std::memcpy(response.data() + header.size(), pOutput, nOutputSize);
size_t responseSize = header.size() + nOutputSize;
std::unique_ptr<char[]> response(new char[responseSize]);
std::memcpy(response.get(), header.data(), header.size());
std::memcpy(response.get() + header.size(), pOutput, nOutputSize);
free(pOutput);
LOG_TRC("Sending response (" << response.size() << " bytes) for shapeselectioncontent on view #" << _viewId);
sendBinaryFrame(response.data(), response.size());
LOG_TRC("Sending response (" << responseSize << " bytes) for shapeselectioncontent on view #" << _viewId);
sendBinaryFrame(response.get(), responseSize);
}
else
{