diff --git a/src/ifcparse/IfcFile.h b/src/ifcparse/IfcFile.h index 0742c2efaa..54f3cb8378 100644 --- a/src/ifcparse/IfcFile.h +++ b/src/ifcparse/IfcFile.h @@ -130,7 +130,7 @@ private: const IfcParse::schema_definition* schema_; const IfcParse::declaration* ifcroot_type_; - std::vector internal_attribute_vector_; + std::vector internal_attribute_vector_, internal_attribute_vector_simple_type_; entity_by_id_t byid; entities_by_type_t bytype; diff --git a/src/ifcparse/IfcParse.cpp b/src/ifcparse/IfcParse.cpp index b706c550f5..4cfd4ae3bd 100644 --- a/src/ifcparse/IfcParse.cpp +++ b/src/ifcparse/IfcParse.cpp @@ -699,7 +699,11 @@ size_t IfcParse::IfcFile::load(unsigned entity_instance_name, const IfcParse::en // If num_attributes is zero we know this is a top-level entity instance (or header entity) being parsed. // There can only be parsed one of these at a time, so we can reuse the vector we have defined at the file // scope. - vector = &internal_attribute_vector_; + if (entity) { + vector = &internal_attribute_vector_; + } else { + vector = &internal_attribute_vector_simple_type_; + } vector->clear(); } else { vector = new std::vector; @@ -758,7 +762,7 @@ size_t IfcParse::IfcFile::load(unsigned entity_instance_name, const IfcParse::en attributes[i] = vector->at(i); } - if (vector != &internal_attribute_vector_) { + if ((vector != &internal_attribute_vector_) && (vector != &internal_attribute_vector_simple_type_)) { delete vector; } } @@ -1487,6 +1491,7 @@ void IfcFile::initialize_(IfcParse::IfcSpfStream* s) { // prevent heap allocations during parse internal_attribute_vector_.reserve(64); + internal_attribute_vector_simple_type_.reserve(16); parsing_complete_ = false; MaxId = 0;