diff options
author | Michael Meeks <michael.meeks@collabora.com> | 2013-11-20 12:11:44 +0000 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2013-11-20 12:12:50 +0000 |
commit | 9491ca3f64bd44a6a8e63f7d2eae02164f792258 (patch) | |
tree | 5ed4973014c2fe04d5e67dd792ee2229c51928fa /sax | |
parent | 55716b1ed969073f273c00baedb56d8f5de93761 (diff) |
fastparser: avoid excessive alloc/frees for int / bool / double parsing
Change-Id: I596bbc723558f04588d9e767d64732164524e57a
Diffstat (limited to 'sax')
-rw-r--r-- | sax/source/tools/fastattribs.cxx | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/sax/source/tools/fastattribs.cxx b/sax/source/tools/fastattribs.cxx index 2297b1d53fc1..1705c3089dd4 100644 --- a/sax/source/tools/fastattribs.cxx +++ b/sax/source/tools/fastattribs.cxx @@ -132,6 +132,31 @@ sal_Int32 FastAttributeList::getOptionalValueToken( ::sal_Int32 Token, ::sal_Int return Default; } +// performance sensitive shortcuts to avoid allocation ... +bool FastAttributeList::getAsInteger( sal_Int32 nToken, sal_Int32 &rInt) +{ + rInt = 0; + for (size_t i = 0; i < maAttributeTokens.size(); ++i) + if (maAttributeTokens[i] == nToken) + { + rInt = rtl_str_toInt32( mpChunk + maAttributeValues[i], 10 ); + return true; + } + return false; +} + +bool FastAttributeList::getAsDouble( sal_Int32 nToken, double &rDouble) +{ + rDouble = 0.0; + for (size_t i = 0; i < maAttributeTokens.size(); ++i) + if (maAttributeTokens[i] == nToken) + { + rDouble = rtl_str_toDouble( mpChunk + maAttributeValues[i] ); + return true; + } + return false; +} + OUString FastAttributeList::getValue( ::sal_Int32 Token ) throw (SAXException, RuntimeException) { for (size_t i = 0; i < maAttributeTokens.size(); ++i) |