diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-04-10 20:17:54 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-04-11 14:45:38 +0200 |
commit | 85c2ed8dc790689ce69ff0a08ff5a4de98df54b7 (patch) | |
tree | f7d7f6fce51d1a4443608971da7d9c42b1201fa3 /comphelper | |
parent | 117688bd3f51a7a50b2620aa7dcc0c065f29d402 (diff) |
loplugin:stringview add check for getToken().toInt32
where we can convert that to
o3tl::toInt32(o3tl::getToken(
and avoid the heap allocation of a temporary string
Change-Id: Ib11c19c6e6cdc0de3e551affd3578d181e292de4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132810
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'comphelper')
-rw-r--r-- | comphelper/source/misc/sequenceashashmap.cxx | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/comphelper/source/misc/sequenceashashmap.cxx b/comphelper/source/misc/sequenceashashmap.cxx index c6ac57326935..b2021e7b85fa 100644 --- a/comphelper/source/misc/sequenceashashmap.cxx +++ b/comphelper/source/misc/sequenceashashmap.cxx @@ -30,6 +30,7 @@ #include <comphelper/processfactory.hxx> #include <comphelper/propertysequence.hxx> #include <sal/log.hxx> +#include <o3tl/string_view.hxx> using namespace com::sun::star; @@ -73,17 +74,17 @@ uno::Any jsonToUnoAny(const boost::property_tree::ptree& aTree) if (aTypeClass == uno::TypeClass_VOID) aAny.clear(); else if (aTypeClass == uno::TypeClass_BYTE) - aAny <<= static_cast<sal_Int8>(OString(rValue.c_str()).toInt32()); + aAny <<= static_cast<sal_Int8>(o3tl::toInt32(rValue)); else if (aTypeClass == uno::TypeClass_BOOLEAN) aAny <<= OString(rValue.c_str()).toBoolean(); else if (aTypeClass == uno::TypeClass_SHORT) - aAny <<= static_cast<sal_Int16>(OString(rValue.c_str()).toInt32()); + aAny <<= static_cast<sal_Int16>(o3tl::toInt32(rValue)); else if (aTypeClass == uno::TypeClass_UNSIGNED_SHORT) aAny <<= static_cast<sal_uInt16>(OString(rValue.c_str()).toUInt32()); else if (aTypeClass == uno::TypeClass_LONG) - aAny <<= OString(rValue.c_str()).toInt32(); + aAny <<= o3tl::toInt32(rValue); else if (aTypeClass == uno::TypeClass_UNSIGNED_LONG) - aAny <<= static_cast<sal_uInt32>(OString(rValue.c_str()).toInt32()); + aAny <<= static_cast<sal_uInt32>(o3tl::toInt32(rValue)); else if (aTypeClass == uno::TypeClass_FLOAT) aAny <<= OString(rValue.c_str()).toFloat(); else if (aTypeClass == uno::TypeClass_DOUBLE) @@ -326,17 +327,17 @@ std::vector<css::beans::PropertyValue> JsonToPropertyValues(const OString& rJson else if (rType == "float") aValue.Value <<= OString(rValue.c_str()).toFloat(); else if (rType == "long") - aValue.Value <<= OString(rValue.c_str()).toInt32(); + aValue.Value <<= o3tl::toInt32(rValue); else if (rType == "short") - aValue.Value <<= sal_Int16(OString(rValue.c_str()).toInt32()); + aValue.Value <<= sal_Int16(o3tl::toInt32(rValue)); else if (rType == "unsigned short") aValue.Value <<= sal_uInt16(OString(rValue.c_str()).toUInt32()); else if (rType == "int64") - aValue.Value <<= OString(rValue.c_str()).toInt64(); + aValue.Value <<= o3tl::toInt64(rValue); else if (rType == "int32") - aValue.Value <<= OString(rValue.c_str()).toInt32(); + aValue.Value <<= o3tl::toInt32(rValue); else if (rType == "int16") - aValue.Value <<= sal_Int16(OString(rValue.c_str()).toInt32()); + aValue.Value <<= sal_Int16(o3tl::toInt32(rValue)); else if (rType == "uint64") aValue.Value <<= OString(rValue.c_str()).toUInt64(); else if (rType == "uint32") |