diff options
author | Rye Mutt <rye@alchemyviewer.org> | 2022-09-27 17:58:01 -0400 |
---|---|---|
committer | Rye Mutt <rye@alchemyviewer.org> | 2022-09-27 17:59:21 -0400 |
commit | 9f633e087fa0855ee8358e3e84924872ec5d965f (patch) | |
tree | f3302e9ee8fdac5ef17c43ce71c866575a6664ec /indra/newview/llmeshrepository.cpp | |
parent | 07449892df0cfcfa22583d7d7c7b29098e3af499 (diff) |
Optimize away many string copies in mesh header processing with boost iostream array adapters
Diffstat (limited to 'indra/newview/llmeshrepository.cpp')
-rw-r--r-- | indra/newview/llmeshrepository.cpp | 25 |
1 files changed, 6 insertions, 19 deletions
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("<? LLSD/Binary ?>"); + 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<boost::iostreams::array_source> stream(result_ptr, data_size); if (!LLSDSerialize::fromBinary(header, stream, data_size)) { |