3 ms·
The sort, OK, but the URINameSpace lookups? I think all the other elements of parsing XML take so much more time that in this case the "optimization" is really
by Tichy 18y ago
The sort, OK, but the URINameSpace lookups? I think all the other elements of parsing XML take so much more time that in this case the "optimization" is really nonsense. I mean even having spent time on optimizing that code was probably a waste, premature optimization. (I have never written an XML parser with namespaces, though).
- scott_s 18y agoKey word you said: "I think." Yet the code was taken from an actual XML parser, where one of the goals is performance. The optimization is likely the result of experience and data.
- ajross 18y agoXML parsing can be done with a simple tag stack and a linear walk through the document. It's very cheap. And a quick loop over 6 (or whatever) strings in L1 cache can easily be faster than a generalized hash table lookup. Given that the namespace tag lookup isn't a huge deal anyway (just walk up the stack doing a string comparison at each level), any optimization needs to be pretty lean to start with. I'd guess that the hash thing is probably a wash; this is the only technique likely to work well.