Opened 13 years ago
Closed 13 years ago
#695 closed task (fixed)
[PATCH] Stop using boost::filesystem::operator< so much
Reported by: | Philip Taylor | Owned by: | Rodolphe Ortalo |
---|---|---|---|
Priority: | Nice to Have | Milestone: | Alpha 4 |
Component: | Core engine | Keywords: | simple |
Cc: | Jan Wassenberg | Patch: |
Description
When launching the game and starting a map, Callgrind says boost::filesystem::operator<
accounts for about 14% of instructions executed, which is a stupid waste. It's called about 90,000 times and does about 800,000 memory allocations (it's not just a straight string comparison).
The main callers are
CTextureManagerImpl::CreateTexture CTextureManagerImpl::GetConverterSettings CTextureManagerImpl::GetSettingsFile CSkeletonAnimManager::GetAnimation Landlord<>::add_ FileCache::Retrieve
which look like std::map<VfsPath, ...>
. If these places don't care about ordered iteration, they should probably use a hash map instead. If they do care, they should probably store strings instead of VfsPath
s so that lookups are cheaper.
Attachments (1)
Change History (6)
comment:1 by , 13 years ago
Cc: | added |
---|
comment:2 by , 13 years ago
Owner: | set to |
---|---|
Status: | new → assigned |
comment:3 by , 13 years ago
Keywords: | review added |
---|
comment:4 by , 13 years ago
Summary: | Stop using boost::filesystem::operator< so much → [PATCH] Stop using boost::filesystem::operator< so much |
---|
comment:5 by , 13 years ago
Keywords: | review removed |
---|---|
Resolution: | → fixed |
Status: | assigned → closed |
Committed (along with a few more set -> unordered_set in CGUI), thanks!
Note:
See TracTickets
for help on using tickets.
Attached patch should bring usage of this operator to nearly 0. I followed your hints, and also changed the set type of the TextureCache object to boost::unordered_set to eliminate the last 23000 calls. (Checked with Callgrind.) Hope the patch is correct (have not done C++ for a while).
Please, feedback.