Remove virtual kind() call out of compile-time loop

This commit is contained in:
Thomas Krijnen
2023-12-19 12:38:22 +01:00
parent ca4781f559
commit 89fd887d9a
2 changed files with 5 additions and 5 deletions
+1 -1
View File
@@ -26,7 +26,7 @@ bool ifcopenshell::geometry::kernels::AbstractKernel::convert(const taxonomy::pt
// std::wcout << sss.c_str() << std::endl;
try {
return dispatch_conversion<0>::dispatch(this, item, results);
return dispatch_conversion<0>::dispatch(this, item->kind(), item, results);
} catch (std::exception& e) {
Logger::Error(e, item->instance);
return false;
+4 -4
View File
@@ -79,19 +79,19 @@ namespace {
/* A compile-time for loop over the taxonomy kinds */
template <size_t N>
struct dispatch_conversion {
static bool dispatch(ifcopenshell::geometry::kernels::AbstractKernel* kernel, const ifcopenshell::geometry::taxonomy::ptr item, IfcGeom::ConversionResults& results) {
if (N == item->kind()) {
static bool dispatch(ifcopenshell::geometry::kernels::AbstractKernel* kernel, ifcopenshell::geometry::taxonomy::kinds item_kind, const ifcopenshell::geometry::taxonomy::ptr item, IfcGeom::ConversionResults& results) {
if (N == item_kind) {
auto concrete_item = ifcopenshell::geometry::taxonomy::template cast<ifcopenshell::geometry::taxonomy::type_by_kind::type<N>>(item);
return kernel->convert_impl(concrete_item, results);
} else {
return dispatch_conversion<N + 1>::dispatch(kernel, item, results);
return dispatch_conversion<N + 1>::dispatch(kernel, item_kind, item, results);
}
}
};
template <>
struct dispatch_conversion<ifcopenshell::geometry::taxonomy::type_by_kind::max> {
static bool dispatch(ifcopenshell::geometry::kernels::AbstractKernel*, const ifcopenshell::geometry::taxonomy::ptr item, IfcGeom::ConversionResults&) {
static bool dispatch(ifcopenshell::geometry::kernels::AbstractKernel*, ifcopenshell::geometry::taxonomy::kinds item_kind, const ifcopenshell::geometry::taxonomy::ptr item, IfcGeom::ConversionResults&) {
Logger::Error("No conversion for " + std::to_string(item->kind()));
return false;
}