diff options
author | Stefan Radomski <github@mintwerk.de> | 2017-07-10 15:13:06 (GMT) |
---|---|---|
committer | Stefan Radomski <github@mintwerk.de> | 2017-07-10 15:13:06 (GMT) |
commit | 286f8d747d198a66b81396ba8197b101ae2d59ed (patch) | |
tree | 2ad222fdbcb2ba6f7ead0ca41e5a6d98ae4c4287 /src/uscxml/util | |
parent | 799a95c560338643894ffd80510db8b48baa2f45 (diff) | |
download | uscxml-286f8d747d198a66b81396ba8197b101ae2d59ed.zip uscxml-286f8d747d198a66b81396ba8197b101ae2d59ed.tar.gz uscxml-286f8d747d198a66b81396ba8197b101ae2d59ed.tar.bz2 |
More performance for microsteppers
Diffstat (limited to 'src/uscxml/util')
-rw-r--r-- | src/uscxml/util/Convenience.cpp | 5 | ||||
-rw-r--r-- | src/uscxml/util/DOM.h | 6 | ||||
-rw-r--r-- | src/uscxml/util/Predicates.cpp | 16 |
3 files changed, 19 insertions, 8 deletions
diff --git a/src/uscxml/util/Convenience.cpp b/src/uscxml/util/Convenience.cpp index 4f47449..4cfbb5e 100644 --- a/src/uscxml/util/Convenience.cpp +++ b/src/uscxml/util/Convenience.cpp @@ -61,6 +61,10 @@ bool isInteger(const char* pszInput, int nNumberBase) { bool iequals(const std::string& a, const std::string& b) { // this impementation beats boost::iequals 2700ms vs 2100ms for test-performance.scxml - we don't care for non-ascii yet +#if 0 + // not platform independent? + return strcasecmp(a.c_str(), b.c_str()) == 0; +#else unsigned int size = a.size(); if (b.size() != size) return false; @@ -68,6 +72,7 @@ bool iequals(const std::string& a, const std::string& b) { if (tolower(a[i]) != tolower(b[i])) return false; return true; +#endif } bool equals(const std::string& a, const std::string& b) { diff --git a/src/uscxml/util/DOM.h b/src/uscxml/util/DOM.h index 2adc675..1e0b8ce 100644 --- a/src/uscxml/util/DOM.h +++ b/src/uscxml/util/DOM.h @@ -201,6 +201,10 @@ public : return _localForm; } + int iequals(const XMLCh* const other) const { + return XERCESC_NS::XMLString::compareIString(_unicodeForm, other); + } + operator XMLCh* () const { assert(_unicodeForm != NULL); // constructor with XMLCh return _unicodeForm; @@ -217,7 +221,7 @@ public : } bool operator==(const X& other) const { - return (_unicodeForm == other._unicodeForm) != 0; + return (_localForm == other._localForm) != 0; } bool operator!=(const X& other) const { diff --git a/src/uscxml/util/Predicates.cpp b/src/uscxml/util/Predicates.cpp index 3f6128f..6649907 100644 --- a/src/uscxml/util/Predicates.cpp +++ b/src/uscxml/util/Predicates.cpp @@ -183,21 +183,23 @@ bool isState(const DOMElement* state, bool properOnly) { if (!state) return false; - std::string localName = LOCALNAME(state); - if (iequals("state", localName)) + // comparison with XMLCh* is faster than transcoding each + const XMLCh* localname = state->getLocalName(); + + if (kXMLCharState.iequals(localname) == 0) return true; - if (iequals("scxml", localName)) + if (kXMLCharScxml.iequals(localname) == 0) return true; - if (iequals("parallel", localName)) + if (kXMLCharParallel.iequals(localname) == 0) return true; - if (iequals("final", localName)) + if (kXMLCharFinal.iequals(localname) == 0) return true; if (properOnly) return false; - if (iequals("history", localName)) + if (kXMLCharHistory.iequals(localname) == 0) return true; - if (iequals("initial", localName)) + if (kXMLCharInitial.iequals(localname) == 0) return true; return false; |