From 36e157254c3ee81163b5d39b1f91107095cd7e09 Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Sun, 25 Jun 2023 18:25:45 -0600 Subject: [PATCH] build perf: de-templateize texvec, we only need texvecf --- common/bspfile.cc | 16 ++++++++++++++++ common/decompile.cc | 3 +-- include/common/bspfile.hh | 28 ++++++---------------------- 3 files changed, 23 insertions(+), 24 deletions(-) diff --git a/common/bspfile.cc b/common/bspfile.cc index b710eec9..9cb66c2d 100644 --- a/common/bspfile.cc +++ b/common/bspfile.cc @@ -2429,6 +2429,22 @@ inline void ReadQ2BSP(lump_reader &reader, T &bsp) reader.read(Q2_LUMP_AREAPORTALS, bsp.dareaportals); } +void texvecf::stream_read(std::istream &stream) +{ + for (size_t i = 0; i < 2; i++) + for (size_t x = 0; x < 4; x++) { + stream >= this->at(i, x); + } +} + +void texvecf::stream_write(std::ostream &stream) const +{ + for (size_t i = 0; i < 2; i++) + for (size_t x = 0; x < 4; x++) { + stream <= this->at(i, x); + } +} + void bspdata_t::bspxentries::transfer(const char *xname, std::vector &xdata) { entries.insert_or_assign(xname, std::move(xdata)); diff --git a/common/decompile.cc b/common/decompile.cc index 4c3b62fb..6446a590 100644 --- a/common/decompile.cc +++ b/common/decompile.cc @@ -66,8 +66,7 @@ struct texdef_valve_t } // FIXME: merge with map.cc copy - template - inline texdef_valve_t(const texvec &in_vecs) + inline texdef_valve_t(const texvecf &in_vecs) { // From the valve -> bsp code, // out->vecs[n].xyz = axis[n].xyz / scale[n]; diff --git a/include/common/bspfile.hh b/include/common/bspfile.hh index cd72b437..99934e68 100644 --- a/include/common/bspfile.hh +++ b/include/common/bspfile.hh @@ -371,10 +371,9 @@ struct fmt::formatter } }; -template -struct texvec : qmat +struct texvecf : qmat { - using qmat::qmat; + using qmat::qmat; template constexpr qvec uvs(const qvec &pos) const @@ -392,31 +391,16 @@ struct texvec : qmat // Not blit compatible because qmat is column-major but // texvecs are row-major - void stream_read(std::istream &stream) - { - for (size_t i = 0; i < 2; i++) - for (size_t x = 0; x < 4; x++) { - stream >= this->at(i, x); - } - } - - void stream_write(std::ostream &stream) const - { - for (size_t i = 0; i < 2; i++) - for (size_t x = 0; x < 4; x++) { - stream <= this->at(i, x); - } - } + void stream_read(std::istream &stream); + void stream_write(std::ostream &stream) const; }; // Fmt support -template -struct fmt::formatter> : fmt::formatter> +template<> +struct fmt::formatter : fmt::formatter> { }; -using texvecf = texvec; - // type to store a hull index; max 256 hulls, zero is valid. using hull_index_t = std::optional;