summaryrefslogtreecommitdiffstats
path: root/basegfx/source/tools/stringconversiontools.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'basegfx/source/tools/stringconversiontools.cxx')
-rw-r--r--basegfx/source/tools/stringconversiontools.cxx34
1 files changed, 15 insertions, 19 deletions
diff --git a/basegfx/source/tools/stringconversiontools.cxx b/basegfx/source/tools/stringconversiontools.cxx
index d9f7df14cf50..79b6d604662e 100644
--- a/basegfx/source/tools/stringconversiontools.cxx
+++ b/basegfx/source/tools/stringconversiontools.cxx
@@ -46,70 +46,66 @@ namespace basegfx::internal
static bool getDoubleChar(double& o_fRetval,
sal_Int32& io_rPos,
- const OUString& rStr)
+ std::u16string_view rStr)
{
- sal_Unicode aChar = io_rPos < rStr.getLength() ? rStr[io_rPos] : 0;
- OUStringBuffer sNumberString;
+ const sal_Int64 nStrSize = rStr.size();
+ sal_Unicode aChar = io_rPos < nStrSize ? rStr[io_rPos] : 0;
+ const sal_Int32 nStartPos = io_rPos;
// sign
if(aChar == '+' || aChar == '-')
{
- sNumberString.append(rStr[io_rPos]);
aChar = rStr[++io_rPos];
}
// numbers before point
while('0' <= aChar && '9' >= aChar)
{
- sNumberString.append(rStr[io_rPos]);
io_rPos++;
- aChar = io_rPos < rStr.getLength() ? rStr[io_rPos] : 0;
+ aChar = io_rPos < nStrSize ? rStr[io_rPos] : 0;
}
// point
if(aChar == '.')
{
- sNumberString.append(rStr[io_rPos]);
io_rPos++;
- aChar = io_rPos < rStr.getLength() ? rStr[io_rPos] : 0;
+ aChar = io_rPos < nStrSize ? rStr[io_rPos] : 0;
}
// numbers after point
while ('0' <= aChar && '9' >= aChar)
{
- sNumberString.append(rStr[io_rPos]);
io_rPos++;
- aChar = io_rPos < rStr.getLength() ? rStr[io_rPos] : 0;
+ aChar = io_rPos < nStrSize ? rStr[io_rPos] : 0;
}
// 'e'
if(aChar == 'e' || aChar == 'E')
{
- sNumberString.append(rStr[io_rPos]);
io_rPos++;
- aChar = io_rPos < rStr.getLength() ? rStr[io_rPos] : 0;
+ aChar = io_rPos < nStrSize ? rStr[io_rPos] : 0;
// sign for 'e'
if(aChar == '+' || aChar == '-')
{
- sNumberString.append(rStr[io_rPos]);
io_rPos++;
- aChar = io_rPos < rStr.getLength() ? rStr[io_rPos] : 0;
+ aChar = io_rPos < nStrSize ? rStr[io_rPos] : 0;
}
// number for 'e'
while('0' <= aChar && '9' >= aChar)
{
- sNumberString.append(rStr[io_rPos]);
io_rPos++;
- aChar = io_rPos < rStr.getLength() ? rStr[io_rPos] : 0;
+ aChar = io_rPos < nStrSize ? rStr[io_rPos] : 0;
}
}
- if(sNumberString.getLength())
+ const sal_Int32 nLen = io_rPos - nStartPos;
+ if(nLen)
{
+ rStr = rStr.substr(nStartPos, nLen);
rtl_math_ConversionStatus eStatus;
- o_fRetval = ::rtl::math::stringToDouble( sNumberString.makeStringAndClear(),
+ o_fRetval = ::rtl::math::stringToDouble( rStr,
'.',
',',
&eStatus );
@@ -121,7 +117,7 @@ namespace basegfx::internal
bool importDoubleAndSpaces(double& o_fRetval,
sal_Int32& io_rPos,
- const OUString& rStr,
+ std::u16string_view rStr,
const sal_Int32 nLen )
{
if( !getDoubleChar(o_fRetval, io_rPos, rStr) )