From fe5a23e1101d6c36596040878d333328a09ab026 Mon Sep 17 00:00:00 2001 From: Krishty Date: Mon, 3 May 2021 17:01:59 +0200 Subject: [PATCH] fixed bloat in SIB importer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The SIB importer, upon needing an empty aiString, did not create a new one but rather copied a predefined global empty string. Since aiStrings contain large buffers, Assimp copied 1028 B of zeros instead of setting five bytes (at least when compiled with Visual C++). Since aiString is a user-defined type without a constexpr constructor, Visual C++ had to generate a thread-safe run-time initializer as well. Now it’s just two instructions. --- code/AssetLib/SIB/SIBImporter.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/code/AssetLib/SIB/SIBImporter.cpp b/code/AssetLib/SIB/SIBImporter.cpp index 6898fb65c..f73301c21 100644 --- a/code/AssetLib/SIB/SIBImporter.cpp +++ b/code/AssetLib/SIB/SIBImporter.cpp @@ -179,8 +179,7 @@ static void UnknownChunk(StreamReaderLE * /*stream*/, const SIBChunk &chunk) { // Reads a UTF-16LE string and returns it at UTF-8. static aiString ReadString(StreamReaderLE *stream, uint32_t numWChars) { if (nullptr == stream || 0 == numWChars) { - static const aiString empty; - return empty; + return aiString(); } // Allocate buffers (max expansion is 1 byte -> 4 bytes for UTF-8)