Permalink
Browse files

CXBMCTinyXML: reserve string size exactly what 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)
  • Loading branch information...
Karlson2k committed Aug 19, 2012
1 parent cb8adaa commit 47ed046ff25d4de481b4e91cafacd45a6918cc8a
Showing with 2 additions and 1 deletion.
  1. +2 −1 xbmc/utils/XBMCTinyXML.cpp
@@ -76,7 +76,8 @@ bool CXBMCTinyXML::LoadFile(const CStdString &_filename, TiXmlEncoding encoding)
location.Clear();
CStdString data;
- data.reserve(8 * 1000);
+ int64_t fileSize = file.GetLength();
+ data.reserve( (fileSize > 0) ? fileSize : 8*1000);
StreamIn(&file, &data);
file.Close();

0 comments on commit 47ed046

Please sign in to comment.