use more string_view in stoc
Change-Id: I6552f3daee7b18dbd311ac7e80ebf1e84e36704d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140787 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
|
||||
#include <o3tl/any.hxx>
|
||||
#include <o3tl/safeint.hxx>
|
||||
#include <o3tl/string_view.hxx>
|
||||
#include <osl/diagnose.h>
|
||||
#include <cppuhelper/implbase.hxx>
|
||||
#include <cppuhelper/supportsservice.hxx>
|
||||
@@ -63,26 +64,26 @@ static double round( double aVal )
|
||||
}
|
||||
|
||||
|
||||
static bool getNumericValue( double & rfVal, const OUString & rStr )
|
||||
static bool getNumericValue( double & rfVal, std::u16string_view rStr )
|
||||
{
|
||||
double fRet = rStr.toDouble();
|
||||
double fRet = o3tl::toDouble(rStr);
|
||||
if (fRet == 0.0)
|
||||
{
|
||||
sal_Int32 nLen = rStr.getLength();
|
||||
size_t nLen = rStr.size();
|
||||
if (!nLen || (nLen == 1 && rStr[0] == '0')) // common case
|
||||
{
|
||||
rfVal = 0.0;
|
||||
return true;
|
||||
}
|
||||
|
||||
OUString trim( rStr.trim() );
|
||||
std::u16string_view trim( o3tl::trim(rStr) );
|
||||
|
||||
// try hex
|
||||
sal_Int32 nX = trim.indexOf( 'x' );
|
||||
if (nX < 0)
|
||||
nX = trim.indexOf( 'X' );
|
||||
size_t nX = trim.find( 'x' );
|
||||
if (nX == std::u16string_view::npos)
|
||||
nX = trim.find( 'X' );
|
||||
|
||||
if (nX > 0 && trim[nX-1] == '0') // 0x
|
||||
if (nX > 0 && nX != std::u16string_view::npos && trim[nX-1] == '0') // 0x
|
||||
{
|
||||
bool bNeg = false;
|
||||
switch (nX)
|
||||
@@ -99,7 +100,7 @@ static bool getNumericValue( double & rfVal, const OUString & rStr )
|
||||
return false;
|
||||
}
|
||||
|
||||
OUString aHexRest( trim.copy( nX+1 ) );
|
||||
OUString aHexRest( trim.substr( nX+1 ) );
|
||||
sal_uInt64 nRet = aHexRest.toUInt64( 16 );
|
||||
|
||||
if (nRet == 0)
|
||||
@@ -115,8 +116,8 @@ static bool getNumericValue( double & rfVal, const OUString & rStr )
|
||||
return true;
|
||||
}
|
||||
|
||||
nLen = trim.getLength();
|
||||
sal_Int32 nPos = 0;
|
||||
nLen = trim.size();
|
||||
size_t nPos = 0;
|
||||
|
||||
// skip +/-
|
||||
if (nLen && (trim[0] == '-' || trim[0] == '+'))
|
||||
@@ -145,23 +146,23 @@ static bool getNumericValue( double & rfVal, const OUString & rStr )
|
||||
}
|
||||
|
||||
|
||||
static bool getHyperValue( sal_Int64 & rnVal, const OUString & rStr )
|
||||
static bool getHyperValue( sal_Int64 & rnVal, std::u16string_view rStr )
|
||||
{
|
||||
sal_Int32 nLen = rStr.getLength();
|
||||
size_t nLen = rStr.size();
|
||||
if (!nLen || (nLen == 1 && rStr[0] == '0')) // common case
|
||||
{
|
||||
rnVal = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
OUString trim( rStr.trim() );
|
||||
std::u16string_view trim( o3tl::trim(rStr) );
|
||||
|
||||
// try hex
|
||||
sal_Int32 nX = trim.indexOf( 'x' );
|
||||
if (nX < 0)
|
||||
nX = trim.indexOf( 'X' );
|
||||
size_t nX = trim.find( 'x' );
|
||||
if (nX == std::u16string_view::npos)
|
||||
nX = trim.find( 'X' );
|
||||
|
||||
if (nX >= 0)
|
||||
if (nX != std::u16string_view::npos)
|
||||
{
|
||||
if (nX > 0 && trim[nX-1] == '0') // 0x
|
||||
{
|
||||
@@ -180,7 +181,7 @@ static bool getHyperValue( sal_Int64 & rnVal, const OUString & rStr )
|
||||
return false;
|
||||
}
|
||||
|
||||
OUString aHexRest( trim.copy( nX+1 ) );
|
||||
OUString aHexRest( trim.substr( nX+1 ) );
|
||||
sal_uInt64 nRet = aHexRest.toUInt64( 16 );
|
||||
|
||||
if (nRet == 0)
|
||||
|
||||
@@ -167,10 +167,10 @@ private:
|
||||
};
|
||||
|
||||
css::uno::Reference< css::uri::XUriReference > parseGeneric(
|
||||
OUString const & scheme, OUString const & schemeSpecificPart)
|
||||
OUString const & scheme, std::u16string_view schemeSpecificPart)
|
||||
{
|
||||
sal_Int32 len = schemeSpecificPart.getLength();
|
||||
sal_Int32 i = 0;
|
||||
size_t len = schemeSpecificPart.size();
|
||||
size_t i = 0;
|
||||
bool hasAuthority = false;
|
||||
OUString authority;
|
||||
if (len - i >= 2 && schemeSpecificPart[i] == '/'
|
||||
@@ -183,22 +183,22 @@ css::uno::Reference< css::uri::XUriReference > parseGeneric(
|
||||
++i;
|
||||
}
|
||||
hasAuthority = true;
|
||||
authority = schemeSpecificPart.copy(n, i - n);
|
||||
authority = schemeSpecificPart.substr(n, i - n);
|
||||
}
|
||||
sal_Int32 n = i;
|
||||
i = schemeSpecificPart.indexOf('?', i);
|
||||
if (i == -1) {
|
||||
i = schemeSpecificPart.find('?', i);
|
||||
if (i == std::u16string_view::npos) {
|
||||
i = len;
|
||||
}
|
||||
OUString path = schemeSpecificPart.copy(n, i - n);
|
||||
std::u16string_view path = schemeSpecificPart.substr(n, i - n);
|
||||
bool hasQuery = false;
|
||||
OUString query;
|
||||
if (i != len) {
|
||||
hasQuery = true;
|
||||
query = schemeSpecificPart.copy(i + 1);
|
||||
query = schemeSpecificPart.substr(i + 1);
|
||||
}
|
||||
return new UriReference(
|
||||
scheme, hasAuthority, authority, path, hasQuery, query);
|
||||
scheme, hasAuthority, authority, OUString(path), hasQuery, query);
|
||||
}
|
||||
|
||||
struct Segment {
|
||||
|
||||
Reference in New Issue
Block a user