From 9f633e087fa0855ee8358e3e84924872ec5d965f Mon Sep 17 00:00:00 2001 From: Rye Mutt Date: Tue, 27 Sep 2022 17:58:01 -0400 Subject: Optimize away many string copies in mesh header processing with boost iostream array adapters --- indra/newview/llmeshrepository.cpp | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) (limited to 'indra/newview/llmeshrepository.cpp') diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp index 8c85b30e04..3ed7e9289d 100644 --- a/indra/newview/llmeshrepository.cpp +++ b/indra/newview/llmeshrepository.cpp @@ -77,6 +77,8 @@ #include "lluploaddialog.h" #include "llfloaterreg.h" +#include "boost/iostreams/device/array.hpp" +#include "boost/iostreams/stream.hpp" #include "boost/lexical_cast.hpp" #ifndef LL_WINDOWS @@ -1863,27 +1865,12 @@ EMeshProcessingResult LLMeshRepoThread::headerReceived(const LLVolumeParams& mes U32 header_size = 0; if (data_size > 0) { - std::istringstream stream; - try - { - std::string res_str((char*)data, data_size); - - std::string deprecated_header(""); + U32 dsize = data_size; + char* result_ptr = strip_deprecated_header((char*)data, dsize, &header_size); - if (res_str.substr(0, deprecated_header.size()) == deprecated_header) - { - res_str = res_str.substr(deprecated_header.size() + 1, data_size); - header_size = deprecated_header.size() + 1; - } - data_size = res_str.size(); + data_size = dsize; - stream.str(res_str); - } - catch (std::bad_alloc&) - { - // out of memory, we won't be able to process this mesh - return MESH_OUT_OF_MEMORY; - } + boost::iostreams::stream stream(result_ptr, data_size); if (!LLSDSerialize::fromBinary(header, stream, data_size)) { -- cgit v1.2.3