diff --git a/src/olympic/keel/include/keel/typeconv.hpp b/src/olympic/keel/include/keel/typeconv.hpp index 44511143..e4b3729d 100644 --- a/src/olympic/keel/include/keel/typeconv.hpp +++ b/src/olympic/keel/include/keel/typeconv.hpp @@ -197,22 +197,17 @@ class ConverterFunc final: public BaseConverter { class Converter { private: ox::AllocAlias m_buff{}; - BaseConverter *m_conv{}; public: template static Converter make() noexcept { Converter out; static_assert(sizeof(ConverterFunc) <= sizeof(out.m_buff)); - out.m_conv = new (out.m_buff.data()) ConverterFunc{}; + new (out.m_buff.data()) ConverterFunc{}; return out; } - constexpr Converter() {} - Converter(Converter const &other) noexcept: - m_buff{other.m_buff}, - m_conv{m_buff.data()} {} [[nodiscard]] - BaseConverter const *converter() const noexcept { - return m_conv; + BaseConverter const &converter() const noexcept { + return *m_buff.data(); } }; diff --git a/src/olympic/keel/src/typeconv.cpp b/src/olympic/keel/src/typeconv.cpp index cb96f957..2f3532dd 100644 --- a/src/olympic/keel/src/typeconv.cpp +++ b/src/olympic/keel/src/typeconv.cpp @@ -15,8 +15,8 @@ static ox::Result findConverter( ox::StringViewCR dstTypeName, int const dstTypeVersion) noexcept { for (auto const&c : converters) { - if (c.converter()->matches(srcTypeName, srcTypeVersion, dstTypeName, dstTypeVersion)) { - return c.converter(); + if (c.converter().matches(srcTypeName, srcTypeVersion, dstTypeName, dstTypeVersion)) { + return &c.converter(); } } return ox::Error{1, "Could not find converter"}; @@ -46,14 +46,14 @@ static ox::Result> convert( } // try to chain multiple converters for (auto const&subConverter : converters) { - if (!subConverter.converter()->dstMatches(dstTypeName, dstTypeVersion)) { + if (!subConverter.converter().dstMatches(dstTypeName, dstTypeVersion)) { continue; } const auto [intermediate, chainErr] = convert(ctx, converters, src, srcTypeName, srcTypeVersion, - subConverter.converter()->srcTypeName(), subConverter.converter()->srcTypeVersion()); + subConverter.converter().srcTypeName(), subConverter.converter().srcTypeVersion()); if (!chainErr) { - return subConverter.converter()->convertPtrToPtr(ctx, *intermediate); + return subConverter.converter().convertPtrToPtr(ctx, *intermediate); } } return ox::Error{1, "Could not convert between types"};