summaryrefslogtreecommitdiff
path: root/desktop/source/lib
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2021-09-15 18:46:09 +0200
committerLuboš Luňák <l.lunak@collabora.com>2021-09-16 11:32:40 +0200
commit9c5a9ee14273593ebcc4bf0f1d42583b6f4f3c52 (patch)
treebd81f032eb924cff4406f39c6148e52e477956ce /desktop/source/lib
parentd13b63a9859d653d1aba688a56590aa0ef24b89c (diff)
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.lunak@collabora.com>
Diffstat (limited to 'desktop/source/lib')
-rw-r--r--desktop/source/lib/init.cxx32
1 files changed, 24 insertions, 8 deletions
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)