Use constant time parent enumeration lookup

This commit is contained in:
Thomas Krijnen
2016-03-18 11:14:14 +01:00
parent 28560d164c
commit 0ceef8fe67
10 changed files with 103 additions and 1292 deletions
+17 -6
View File
@@ -985,15 +985,20 @@ bool IfcFile::Init(IfcParse::IfcSpfStream* s) {
}
IfcSchema::Type::Enum ty = entity->type();
do {
for (;;) {
IfcEntityList::ptr instances_by_type = entitiesByType(ty);
if (!instances_by_type) {
instances_by_type = IfcEntityList::ptr(new IfcEntityList());
bytype[ty] = instances_by_type;
}
instances_by_type->push(entity);
ty = IfcSchema::Type::Parent(ty);
} while ( ty > -1 );
boost::optional<IfcSchema::Type::Enum> pt = IfcSchema::Type::Parent(ty);
if (pt) {
ty = *pt;
} else {
break;
}
}
if ( byid.find(currentId) != byid.end() ) {
std::stringstream ss;
@@ -1191,15 +1196,21 @@ IfcUtil::IfcBaseClass* IfcFile::addEntity(IfcUtil::IfcBaseClass* entity) {
// The mapping by entity type is updated.
IfcSchema::Type::Enum ty = entity->type();
do {
for (;;) {
IfcEntityList::ptr instances_by_type = entitiesByType(ty);
if (!instances_by_type) {
instances_by_type = IfcEntityList::ptr(new IfcEntityList());
bytype[ty] = instances_by_type;
}
instances_by_type->push(entity);
ty = IfcSchema::Type::Parent(ty);
} while ( ty > -1 );
boost::optional<IfcSchema::Type::Enum> pt = IfcSchema::Type::Parent(ty);
if (pt) {
ty = *pt;
}
else {
break;
}
}
int new_id = -1;
if (entity->entity->isWritable() && !entity->entity->file) {