Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Reserve xml size if available #1301

Closed
wants to merge 1 commit into from

2 participants

@Karlson2k
Collaborator

If we know the file size, then reserving the correct amount is best.

@Karlson2k Karlson2k 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)
47ed046
@Karlson2k
Collaborator

@jmarshallnz Rewritten.
If it's OK, I'll check other parts for double XML processing (like addons)

@jmarshallnz
Owner

You can probably just remove the Loadfile in the constructor to save changing any other code?

@jmarshallnz jmarshallnz reopened this
@Karlson2k
Collaborator

@jmarshallnz This can break other using of CXBMCTinyXML, as code can expect that XML is already loaded and parsed if it's specified in constructor parameter.

@Karlson2k
Collaborator

And I see a lot of using of CXBMCTinyXML.
It's created and loaded several times on every visible windows transition, so 47ed046 and using of 99acb24 is highly valuable. Other code can be modified similar to 1be538e .

@jmarshallnz
Owner
@jmarshallnz
Owner

Updated master with a proper fix f58303b and be982ba.

Also rewrote CScraperParser::Load to use the more intuitive form in 49b7e5c

@jmarshallnz jmarshallnz reopened this
@Karlson2k
Collaborator

@jmarshallnz Yes, that's better way.
After your fixes there is only one commit for optimization.

@Karlson2k
Collaborator

@jmarshallnz Was last commit wrong?

@LongChair LongChair referenced this pull request from a commit in plexinc/plex-home-theater-public
@LongChair LongChair Fix Go back to save viewMode per subsection #1301 eeb59f3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 19, 2012
  1. @Karlson2k

    CXBMCTinyXML: reserve string size exactly what we need

    Karlson2k authored
    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 page is out of date. Refresh to see the latest.
Showing with 2 additions and 1 deletion.
  1. +2 −1  xbmc/utils/XBMCTinyXML.cpp
View
3  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();
Something went wrong with that request. Please try again.