mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-14 03:14:23 +00:00
Optimize IfcFile::entitiesByReference() by reserving capacity for IfcEntityList in advance.
Around 18.4 % speed-up (avg. of first 2000 calls) when converting a somewhat large (176 MB) file to XML.
This commit is contained in:
committed by
Thomas Krijnen
parent
40c2602b0e
commit
38f7ccdc20
@@ -1793,17 +1793,16 @@ IfcEntityList::ptr IfcFile::entitiesByType(const std::string& t) {
|
||||
|
||||
IfcEntityList::ptr IfcFile::entitiesByReference(int t) {
|
||||
entities_by_ref_t::const_iterator it = byref.find(t);
|
||||
IfcEntityList::ptr return_value;
|
||||
IfcEntityList::ptr ret;
|
||||
if (it != byref.end()) {
|
||||
ret.reset(new IfcEntityList);
|
||||
ret->reserve((unsigned)it->second.size());
|
||||
const std::vector<unsigned>& ids = it->second;
|
||||
for (std::vector<unsigned>::const_iterator jt = ids.begin(); jt != ids.end(); ++jt) {
|
||||
if (!return_value) {
|
||||
return_value.reset(new IfcEntityList);
|
||||
}
|
||||
return_value->push(entityById(*jt));
|
||||
ret->push(entityById(*jt));
|
||||
}
|
||||
}
|
||||
return return_value;
|
||||
return ret;
|
||||
}
|
||||
|
||||
IfcUtil::IfcBaseClass* IfcFile::entityById(int id) {
|
||||
|
||||
Reference in New Issue
Block a user