Reply to: Does using associative arrays slow things down?January 11, 2010 at 6:46 pm
Running two tests on your script as it is written on a particular test file (created with basically random content and approximately 2500 elements) gives me vastly different results, as follows:
As written (FormattingUpdating is turned off then on): about 35 seconds (the vast majority of this time is spent reformatting the entire document)
FormattingUpdating lines commented out but otherwise identical: 3 seconds for the first run, less than 1 second for subsequent runs (probably because either the JScript engine has cached the script, or because the engine is already initialized and Windows can run it faster after caching the DLL)
In this particular case what you are searching for is fairly simple (ie: it does not require a complicated XPath statement and can be easily transformed into some basic logic instead, as I've done). There is no problem with using XPath, however, there can be a trade-off in speed. Only testing will show that for sure. The difference will depend on the size and complexity of the document and the complexity of what needs to be found (ie: the 3rd paragraph of any element containing the attribute foo with the exact value bar would be pretty hard to write using scripting logic, though it could be done of course).