diff --git a/src/core/model/table/typed_column_data.h b/src/core/model/table/typed_column_data.h index 64c211e121..0215448417 100644 --- a/src/core/model/table/typed_column_data.h +++ b/src/core/model/table/typed_column_data.h @@ -5,6 +5,7 @@ #include #include "abstract_column_data.h" +#include "destruct.h" #include "idataset_stream.h" #include "model/types/types.h" #include "relation_data.h" @@ -55,11 +56,7 @@ class TypedColumnData : public model::AbstractColumnData { if (GetValueTypeId(i) == +TypeId::kString || GetValueTypeId(i) == +TypeId::kBigInt || GetValueTypeId(i) == +TypeId::kDate) { std::byte const* value = (mixed) ? mixed->RetrieveValue(data_[i]) : data_[i]; - if (GetValueTypeId(i) == +TypeId::kDate) { - DateType::Destruct(value); - } else { - StringType::Destruct(value); - } + Destruct(GetValueTypeId(i), value); } } } diff --git a/src/core/model/types/destruct.h b/src/core/model/types/destruct.h new file mode 100644 index 0000000000..4064404ccd --- /dev/null +++ b/src/core/model/types/destruct.h @@ -0,0 +1,15 @@ +#pragma once +#include "builtin.h" +#include "date_type.h" +#include "string_type.h" + +namespace model { +inline void Destruct(TypeId type_id, std::byte const* value) { + if (type_id == +TypeId::kString || type_id == +TypeId::kBigInt) { + StringType::Destruct(value); + } + if (type_id == +TypeId::kDate) { + DateType::Destruct(value); + } +} +} // namespace model \ No newline at end of file diff --git a/src/core/model/types/mixed_type.h b/src/core/model/types/mixed_type.h index daaca6d2c6..d092f33cc2 100644 --- a/src/core/model/types/mixed_type.h +++ b/src/core/model/types/mixed_type.h @@ -7,6 +7,7 @@ #include "big_int_type.h" #include "create_type.h" #include "date_type.h" +#include "destruct.h" #include "double_type.h" #include "empty_type.h" #include "int_type.h" @@ -61,12 +62,7 @@ class MixedType final : public Type { void Free(std::byte const* value) const noexcept override { TypeId const type_id = RetrieveTypeId(value); - if (type_id == +TypeId::kString || type_id == +TypeId::kBigInt) { - StringType::Destruct(RetrieveValue(value)); - } - if (type_id == +TypeId::kDate) { - DateType::Destruct(RetrieveValue(value)); - } + Destruct(type_id, RetrieveValue(value)); Type::Free(value); }