diff options
author | Shauren <shauren.trinity@gmail.com> | 2025-06-25 13:38:28 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2025-06-25 13:38:28 +0200 |
commit | 247c25abc98731f67df7061aa3860388140a1dc3 (patch) | |
tree | 4f7c77f22876689bc55a727b9d5aea2bd597a0e0 /src/server/database | |
parent | e284dc0a8025c5e4da65271914c88d9afac95667 (diff) |
Core/Database: Improve code generated by DEFINE_FIELD_ACCESSOR_CACHE
Diffstat (limited to 'src/server/database')
-rw-r--r-- | src/server/database/Database/QueryResultStructured.h | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/server/database/Database/QueryResultStructured.h b/src/server/database/Database/QueryResultStructured.h index 7995e879821..afd17edf5d6 100644 --- a/src/server/database/Database/QueryResultStructured.h +++ b/src/server/database/Database/QueryResultStructured.h @@ -20,6 +20,7 @@ #include <boost/preprocessor/cat.hpp> #include <boost/preprocessor/comma_if.hpp> +#include <boost/preprocessor/facilities/empty.hpp> #include <boost/preprocessor/seq/enum.hpp> #include <boost/preprocessor/seq/for_each.hpp> #include <boost/preprocessor/seq/for_each_i.hpp> @@ -29,11 +30,11 @@ #define DEFINE_FIELD_ACCESSOR_CACHE_FIELD(r, data, field) Field const& field() const\ {\ - return Result.Fetch()[indexes.field];\ + return Fields[indexes.field];\ } -#define DEFINE_FIELD_ACCESSOR_CACHE(struct_name, result_type, fields_list) \ - struct struct_name \ +#define DEFINE_FIELD_ACCESSOR_CACHE(namespace_name, struct_name, result_type, fields_list) \ + struct namespace_name struct_name \ { \ struct Indexes\ {\ @@ -42,11 +43,12 @@ std::size_t BOOST_PP_SEQ_ENUM(fields_list);\ };\ BOOST_PP_SEQ_FOR_EACH(DEFINE_FIELD_ACCESSOR_CACHE_FIELD, ~, fields_list) \ - result_type const& Result; \ + struct_name(result_type const& result) : Fields(result.Fetch()), indexes(indexes_impl(result)) { }\ + Field* Fields; \ static Indexes const& indexes_impl(result_type const& result) { static Indexes const instance(result); return instance; }\ - Indexes const& indexes = indexes_impl(Result);\ + Indexes const& indexes;\ } -#define DEFINE_FIELD_ACCESSOR_CACHE_ANONYMOUS(result_type, fields_list) DEFINE_FIELD_ACCESSOR_CACHE(BOOST_PP_CAT(FieldAccessors, __LINE__), result_type, fields_list) +#define DEFINE_FIELD_ACCESSOR_CACHE_ANONYMOUS(result_type, fields_list) DEFINE_FIELD_ACCESSOR_CACHE(BOOST_PP_EMPTY(), BOOST_PP_CAT(FieldAccessors, __LINE__), result_type, fields_list) #endif // TRINITYCORE_QUERY_RESULT_STRUCTURED_H |