From 4deb2a5fe751c540bda5a109b636ddebf6a0ba07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 5 Jan 2019 19:24:03 +0100 Subject: [PATCH] MeshTools: inline functions should not be heavy. Returning a vector is as heavy as you can imagine. --- src/Magnum/MeshTools/CombineIndexedArrays.cpp | 16 ++++++++++++---- src/Magnum/MeshTools/CombineIndexedArrays.h | 12 ++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Magnum/MeshTools/CombineIndexedArrays.cpp b/src/Magnum/MeshTools/CombineIndexedArrays.cpp index a91cbbee8..b81bdf9c1 100644 --- a/src/Magnum/MeshTools/CombineIndexedArrays.cpp +++ b/src/Magnum/MeshTools/CombineIndexedArrays.cpp @@ -60,6 +60,10 @@ std::pair, std::vector> interleaveAndCombi return {combinedIndices, interleavedArrays}; } +} + +namespace { + std::vector combineIndexArrays(const std::reference_wrapper>* const begin, const std::reference_wrapper>* const end) { /* Interleave and combine the arrays */ std::vector combinedIndices; @@ -83,10 +87,6 @@ std::vector combineIndexArrays(const std::reference_wrapper& indices, UnsignedInt stride): indices(indices), stride(stride) {} @@ -115,6 +115,14 @@ class IndexEqual { } +std::vector combineIndexArrays(const std::vector>>& arrays) { + return combineIndexArrays(&arrays[0], &arrays[0] + arrays.size()); +} + +std::vector combineIndexArrays(std::initializer_list>> arrays) { + return combineIndexArrays(arrays.begin(), arrays.end()); +} + std::pair, std::vector> combineIndexArrays(const std::vector& interleavedArrays, const UnsignedInt stride) { CORRADE_ASSERT(stride != 0, "MeshTools::combineIndexArrays(): stride can't be zero", {}); CORRADE_ASSERT(interleavedArrays.size() % stride == 0, "MeshTools::combineIndexArrays(): array size is not divisible by stride", {}); diff --git a/src/Magnum/MeshTools/CombineIndexedArrays.h b/src/Magnum/MeshTools/CombineIndexedArrays.h index 3bdfb8ed1..ef6aa1482 100644 --- a/src/Magnum/MeshTools/CombineIndexedArrays.h +++ b/src/Magnum/MeshTools/CombineIndexedArrays.h @@ -39,10 +39,6 @@ namespace Magnum { namespace MeshTools { -namespace Implementation { - MAGNUM_MESHTOOLS_EXPORT std::vector combineIndexArrays(const std::reference_wrapper>* begin, const std::reference_wrapper>* end); -} - /** @brief Combine index arrays @param[in,out] arrays Index arrays to combine. These arrays are updated @@ -85,14 +81,10 @@ This function calls @ref combineIndexArrays(const std::vector&, Uns internally. See also @ref combineIndexedArrays() which does the vertex data reordering automatically. */ -inline std::vector combineIndexArrays(const std::vector>>& arrays) { - return Implementation::combineIndexArrays(&arrays[0], &arrays[0] + arrays.size()); -} +MAGNUM_MESHTOOLS_EXPORT std::vector combineIndexArrays(const std::vector>>& arrays); /** @overload */ -inline std::vector combineIndexArrays(std::initializer_list>> arrays) { - return Implementation::combineIndexArrays(arrays.begin(), arrays.end()); -} +MAGNUM_MESHTOOLS_EXPORT std::vector combineIndexArrays(std::initializer_list>> arrays); /** @brief Combine interleaved index arrays