reduce unnecessary OString temporaries
spotted while profiling tdf#108037 Change-Id: I66afa79d7da94c1d3c7d1695ce9c5cf902e1429e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163002 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
#include <com/sun/star/uno/RuntimeException.hpp>
|
||||
#include <com/sun/star/uno/Sequence.hxx>
|
||||
#include <comphelper/sequence.hxx>
|
||||
#include <o3tl/string_view.hxx>
|
||||
#include <rtl/math.h>
|
||||
#include <rtl/string.h>
|
||||
#include <rtl/string.hxx>
|
||||
@@ -99,16 +100,22 @@ bool parseValue(xmlreader::Span const & text, sal_Int16 * value) {
|
||||
bool parseValue(xmlreader::Span const & text, sal_Int32 * value) {
|
||||
assert(text.is() && value != nullptr);
|
||||
// For backwards compatibility, support hexadecimal values:
|
||||
*value =
|
||||
rtl_str_shortenedCompareIgnoreAsciiCase_WithLength(
|
||||
bool bStartWithHexPrefix = rtl_str_shortenedCompareIgnoreAsciiCase_WithLength(
|
||||
text.begin, text.length, RTL_CONSTASCII_STRINGPARAM("0X"),
|
||||
RTL_CONSTASCII_LENGTH("0X")) == 0 ?
|
||||
static_cast< sal_Int32 >(
|
||||
OString(
|
||||
text.begin + RTL_CONSTASCII_LENGTH("0X"),
|
||||
text.length - RTL_CONSTASCII_LENGTH("0X")).toUInt32(16)) :
|
||||
OString(text.begin, text.length).toInt32();
|
||||
//TODO: check valid lexical representation
|
||||
RTL_CONSTASCII_LENGTH("0X")) == 0;
|
||||
|
||||
if (bStartWithHexPrefix)
|
||||
{
|
||||
std::string_view sView(text.begin + RTL_CONSTASCII_LENGTH("0X"),
|
||||
text.length - RTL_CONSTASCII_LENGTH("0X"));
|
||||
*value = static_cast< sal_Int32 >(o3tl::toUInt32(sView, 16));
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string_view sView(text.begin, text.length);
|
||||
*value = o3tl::toInt32(sView);
|
||||
}
|
||||
//TODO: check valid lexical representation
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user