desktop/source/lib/init.cxx | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-)
New commits: commit 79b26048ae03a3ed92446012b6235d6a464bf7b8 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: Fri Sep 17 00:53:29 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> (cherry picked from commit 9c5a9ee14273593ebcc4bf0f1d42583b6f4f3c52) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122122 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index b803d1372a77..c95de6ed4082 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -529,17 +529,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)