desktop/source/lib/init.cxx | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-)
New commits: commit 9c5a9ee14273593ebcc4bf0f1d42583b6f4f3c52 Author: Luboš Luňák <l.lu...@collabora.com> AuthorDate: Wed Sep 15 18:46:09 2021 +0200 Commit: Luboš Luňák <l.lu...@collabora.com> CommitDate: Thu Sep 16 11:32:40 2021 +0200 use our string->number functions instead of std::istringstream This is sort of the other side of the 417f881d20cafe88a02b6489 optimizations. C++ streams are relatively slow. Change-Id: I295cc662ecab68eb23a6cb3a85606a4c95edeb07 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122159 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lu...@collabora.com> diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 9674cdfcaa1d..6ab01d631910 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -524,17 +524,33 @@ RectangleAndPart RectangleAndPart::Create(const std::string& rPayload) return aRet; } - std::istringstream aStream(rPayload); - tools::Long nLeft, nTop, nWidth, nHeight; + // Read '<left>, <top>, <width>, <height>[, <part>]'. C++ streams are simpler but slower. + const char* pos = rPayload.c_str(); + const char* end = rPayload.c_str() + rPayload.size(); + tools::Long nLeft = rtl_str_toInt64_WithLength(pos, 10, end - pos); + while( *pos != ',' ) + ++pos; + ++pos; + assert(pos < end); + tools::Long nTop = rtl_str_toInt64_WithLength(pos, 10, end - pos); + while( *pos != ',' ) + ++pos; + ++pos; + assert(pos < end); + tools::Long nWidth = rtl_str_toInt64_WithLength(pos, 10, end - pos); + while( *pos != ',' ) + ++pos; + ++pos; + assert(pos < end); + tools::Long nHeight = rtl_str_toInt64_WithLength(pos, 10, end - pos); tools::Long nPart = INT_MIN; - char nComma; if (comphelper::LibreOfficeKit::isPartInInvalidation()) { - aStream >> nLeft >> nComma >> nTop >> nComma >> nWidth >> nComma >> nHeight >> nComma >> nPart; - } - else - { - aStream >> nLeft >> nComma >> nTop >> nComma >> nWidth >> nComma >> nHeight; + while( *pos != ',' ) + ++pos; + ++pos; + assert(pos < end); + nPart = rtl_str_toInt64_WithLength(pos, 10, end - pos); } if (nWidth > 0 && nHeight > 0)