From: terencehill Date: Thu, 31 Oct 2024 22:01:05 +0000 (+0100) Subject: Reduce code duplication in REGISTER_STAT X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=ab43b7a03b799962601a09b1c3283a6fed1e6f94;p=xonotic%2Fxonotic-data.pk3dir.git Reduce code duplication in REGISTER_STAT This change slightly improves compilation performance since it avoids generating about 120KB of completely useless qc code both from server and client code --- diff --git a/qcsrc/lib/stats.qh b/qcsrc/lib/stats.qh index af695b7ba..074f9fcc1 100644 --- a/qcsrc/lib/stats.qh +++ b/qcsrc/lib/stats.qh @@ -66,6 +66,14 @@ int g_magic_stats_hole = 0; #define type_VECTOR vector #define type_VECTORI vector +#define _REGISTRY_RESERVE_INT(Stats, m_id, id) +#define _REGISTRY_RESERVE_BOOL(Stats, m_id, id) +#define _REGISTRY_RESERVE_FLOAT(Stats, m_id, id) +#define _REGISTRY_RESERVE_VECTOR(Stats, m_id, id) \ + REGISTRY_RESERVE(Stats, m_id, STAT_##id, y); \ + REGISTRY_RESERVE(Stats, m_id, STAT_##id, z); +#define _REGISTRY_RESERVE_VECTORI(Stats, m_id, id) _REGISTRY_RESERVE_VECTOR(Stats, m_id, id) + #define REGISTER_STAT(...) EVAL_REGISTER_STAT(OVERLOAD(REGISTER_STAT, __VA_ARGS__)) #define EVAL_REGISTER_STAT(...) __VA_ARGS__ #if defined(CSQC) @@ -88,10 +96,7 @@ int g_magic_stats_hole = 0; /* T CAT(_STAT(id), _prev); */ \ REGISTER(Stats, STAT_##id, m_id, new_pure(stat)) \ { \ - if (#T == "VECTOR" || #T == "VECTORI") { \ - REGISTRY_RESERVE(Stats, m_id, STAT_##id, y); \ - REGISTRY_RESERVE(Stats, m_id, STAT_##id, z); \ - } \ + _REGISTRY_RESERVE_##T(Stats, m_id, id) \ } \ ACCUMULATE void stats_get() \ { \ @@ -146,10 +151,7 @@ int g_magic_stats_hole = 0; .type_##T _STAT(id); \ REGISTER(Stats, STAT_##id, m_id, new_pure(stat)) \ { \ - if (#T == "VECTOR" || #T == "VECTORI") { \ - REGISTRY_RESERVE(Stats, m_id, STAT_##id, y); \ - REGISTRY_RESERVE(Stats, m_id, STAT_##id, z); \ - } \ + _REGISTRY_RESERVE_##T(Stats, m_id, id) \ } \ ACCUMULATE void stats_add() \ { \