xbmc/xbmc — pull request #1445 by Karlson2k (2012-09-19 21:21:49+00:00)
Title: CXBMCTinyXML: use reserve buffer size exactly that we need

On small files this will prevent oversized allocation (and will be faster), on huge file this will prevent multiple reallocation of CStdString (and will be faster)

This is a second try for #1301, but now with some numbers:

Some test:
original code, 1126 KB XML file, 5 times "create object, open file":
6001 milliseconds
5573 milliseconds
6613 milliseconds
5746 milliseconds
5589 milliseconds
5032 milliseconds
6703 milliseconds
5511 milliseconds
5739 milliseconds
5950 milliseconds
6388 milliseconds
6011 milliseconds

patched code,1126 KB XML file, 5 times "create object, open file":
6296 milliseconds
5352 milliseconds
6280 milliseconds
5863 milliseconds
5705 milliseconds
5633 milliseconds
5897 milliseconds
5624 milliseconds
5248 milliseconds
6643 milliseconds
6051 milliseconds
**On average, patched code is better, but not significantly.**

original code, 516 B XML file, 10000 times "create object, open file":
7605 milliseconds
5874 milliseconds
7998 milliseconds
7590 milliseconds
8030 milliseconds
8388 milliseconds
5789 milliseconds
7849 milliseconds
7455 milliseconds
5951 milliseconds
7691 milliseconds

patched code, 516 B XML file, 10000 times "create object, open file":
6008 milliseconds
5929 milliseconds
6139 milliseconds
5623 milliseconds
5633 milliseconds
5804 milliseconds
5825 milliseconds
5652 milliseconds
5656 milliseconds
5697 milliseconds
5841 milliseconds
**So on small files we save about 20-30%.**