diff options
author | Mohammed Abdul Azeem <azeemmysore@gmail.com> | 2017-08-09 21:36:12 +0530 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2017-08-12 16:03:40 +0200 |
commit | dfac13b483ba38ce6f61cd0a1e5757c6a08ab296 (patch) | |
tree | d8bc427ccda762d54d0d42d31cdb9db646f569f1 /sc/source/filter/xml/xmlimprt.cxx | |
parent | 6d34c6eed0a35ac5db918baf742692241c2dc5e9 (diff) |
Avoiding unnecessary OUString allocation:
Using direct strcmp instead of mapping. This is one
of the hotspots and will help improve performance.
Change-Id: I97a452984d53a6746f477ffe4be2806d9e89eee4
Reviewed-on: https://gerrit.libreoffice.org/40928
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Diffstat (limited to 'sc/source/filter/xml/xmlimprt.cxx')
-rw-r--r-- | sc/source/filter/xml/xmlimprt.cxx | 59 |
1 files changed, 37 insertions, 22 deletions
diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx index 339b433dc919..2893c9e354e1 100644 --- a/sc/source/filter/xml/xmlimprt.cxx +++ b/sc/source/filter/xml/xmlimprt.cxx @@ -809,23 +809,6 @@ ScXMLImport::ScXMLImport( GetXMLToken( XML_NP_PRESENTATION ), GetXMLToken( XML_N_PRESENTATION ), XML_NAMESPACE_PRESENTATION ); - - // initialize cell type map. - const struct { XMLTokenEnum _token; sal_Int16 _type; } aCellTypePairs[] = - { - { XML_FLOAT, util::NumberFormat::NUMBER }, - { XML_STRING, util::NumberFormat::TEXT }, - { XML_TIME, util::NumberFormat::TIME }, - { XML_DATE, util::NumberFormat::DATETIME }, - { XML_PERCENTAGE, util::NumberFormat::PERCENT }, - { XML_CURRENCY, util::NumberFormat::CURRENCY }, - { XML_BOOLEAN, util::NumberFormat::LOGICAL } - }; - for (const auto & aCellTypePair : aCellTypePairs) - { - aCellTypeMap.emplace( - GetXMLToken(aCellTypePair._token), aCellTypePair._type); - } } ScXMLImport::~ScXMLImport() throw() @@ -1021,13 +1004,45 @@ ScDocumentImport& ScXMLImport::GetDoc() return *mpDocImport; } -sal_Int16 ScXMLImport::GetCellType(const OUString& rStrValue) const +sal_Int16 ScXMLImport::GetCellType(const char* rStrValue, const sal_Int32 nStrLength) { - CellTypeMap::const_iterator itr = aCellTypeMap.find(rStrValue); - if (itr != aCellTypeMap.end()) - return itr->second; + sal_Int16 nCellType = util::NumberFormat::UNDEFINED; + if (rStrValue != nullptr) + { + switch (rStrValue[0]) + { + case 'b': + if (nStrLength == 7 && !strcmp(rStrValue, "boolean")) + nCellType = util::NumberFormat::LOGICAL; + break; + case 'c': + if (nStrLength == 8 && !strcmp(rStrValue, "currency")) + nCellType = util::NumberFormat::CURRENCY; + break; + case 'd': + if (nStrLength == 4 && !strcmp(rStrValue, "date")) + nCellType = util::NumberFormat::DATETIME; + break; + case 'f': + if (nStrLength == 5 && !strcmp(rStrValue, "float")) + nCellType = util::NumberFormat::NUMBER; + break; + case 'p': + if (nStrLength == 10 && !strcmp(rStrValue, "percentage")) + nCellType = util::NumberFormat::PERCENT; + break; + case 's': + if (nStrLength == 6 && !strcmp(rStrValue, "string")) + nCellType = util::NumberFormat::TEXT; + break; + case 't': + if (nStrLength == 4 && !strcmp(rStrValue, "time")) + nCellType = util::NumberFormat::TIME; + break; + } + } - return util::NumberFormat::UNDEFINED; + return nCellType; } XMLShapeImportHelper* ScXMLImport::CreateShapeImport() |