diff options
author | Alexander Gavriliuk <alexandrgproductengine@lindenlab.com> | 2024-03-05 17:03:11 +0100 |
---|---|---|
committer | Guru <alexandrgproductengine@lindenlab.com> | 2024-03-05 19:54:31 +0100 |
commit | a865d423974ea06dffa47798c81e98e7570b02ec (patch) | |
tree | d25f6c86d2948f7d8683aaa573d24135c8a26edb /indra/llui/llxuiparser.cpp | |
parent | 043a92997f187826ad26ff269613c8f0ed11379f (diff) |
viewer#819 Avoid reading the same XML file multiple times
Diffstat (limited to 'indra/llui/llxuiparser.cpp')
-rw-r--r-- | indra/llui/llxuiparser.cpp | 27 |
1 files changed, 5 insertions, 22 deletions
diff --git a/indra/llui/llxuiparser.cpp b/indra/llui/llxuiparser.cpp index a60ccb537e..84507a58b6 100644 --- a/indra/llui/llxuiparser.cpp +++ b/indra/llui/llxuiparser.cpp @@ -28,6 +28,7 @@ #include "llxuiparser.h" +#include "lldir.h" #include "llxmlnode.h" #include "llfasttimer.h" #ifdef LL_USESYSTEMLIBS @@ -44,6 +45,7 @@ #include "lluicolor.h" #include "v3math.h" + using namespace BOOST_SPIRIT_CLASSIC_NS; const S32 MAX_STRING_ATTRIBUTE_SIZE = 40; @@ -1397,36 +1399,17 @@ bool LLSimpleXUIParser::readXUI(const std::string& filename, LLInitParam::BaseBl mCurReadDepth = 0; setParseSilently(silent); - ScopedFile file(filename, "rb"); - if( !file.isOpen() ) + std::string xml = gDirUtilp->getFileContents(filename); + if (xml.empty()) { LL_WARNS("ReadXUI") << "Unable to open file " << filename << LL_ENDL; XML_ParserFree( mParser ); return false; } - S32 bytes_read = 0; - - S32 buffer_size = file.getRemainingBytes(); - void* buffer = XML_GetBuffer(mParser, buffer_size); - if( !buffer ) - { - LL_WARNS("ReadXUI") << "Unable to allocate XML buffer while reading file " << filename << LL_ENDL; - XML_ParserFree( mParser ); - return false; - } - - bytes_read = (S32)fread(buffer, 1, buffer_size, file.mFile); - if( bytes_read <= 0 ) - { - LL_WARNS("ReadXUI") << "Error while reading file " << filename << LL_ENDL; - XML_ParserFree( mParser ); - return false; - } - mEmptyLeafNode.push_back(false); - if( !XML_ParseBuffer(mParser, bytes_read, true ) ) + if (!XML_Parse(mParser, xml.data(), (int)xml.size(), true)) { LL_WARNS("ReadXUI") << "Error while parsing file " << filename << LL_ENDL; XML_ParserFree( mParser ); |