From 60a313a687c5380c4a6d1a451936c85db07b681a Mon Sep 17 00:00:00 2001 From: Richard Nelson Date: Fri, 6 Aug 2010 11:02:37 -0700 Subject: speed up population of region scripts list --- indra/newview/llfloaterscriptlimits.cpp | 62 ++++++++++++++++++--------------- 1 file changed, 34 insertions(+), 28 deletions(-) (limited to 'indra') diff --git a/indra/newview/llfloaterscriptlimits.cpp b/indra/newview/llfloaterscriptlimits.cpp index e827e19f82..a77fc4710a 100644 --- a/indra/newview/llfloaterscriptlimits.cpp +++ b/indra/newview/llfloaterscriptlimits.cpp @@ -712,38 +712,44 @@ void LLPanelScriptLimitsRegionMemory::setRegionDetails(LLSD content) } } - LLSD element; + LLScrollListItem::Params item_params; + item_params.value = task_id; - element["id"] = task_id; - element["columns"][0]["column"] = "size"; - element["columns"][0]["value"] = llformat("%d", size); - element["columns"][0]["font"] = "SANSSERIF"; - element["columns"][1]["column"] = "urls"; - element["columns"][1]["value"] = llformat("%d", urls); - element["columns"][1]["font"] = "SANSSERIF"; - element["columns"][2]["column"] = "name"; - element["columns"][2]["value"] = name_buf; - element["columns"][2]["font"] = "SANSSERIF"; - element["columns"][3]["column"] = "owner"; - element["columns"][3]["value"] = owner_buf; - element["columns"][3]["font"] = "SANSSERIF"; - element["columns"][4]["column"] = "parcel"; - element["columns"][4]["value"] = parcel_name; - element["columns"][4]["font"] = "SANSSERIF"; - element["columns"][5]["column"] = "location"; - if(has_locations) - { - element["columns"][5]["value"] = llformat("<%0.1f,%0.1f,%0.1f>", location_x, location_y, location_z); - } - else - { - element["columns"][5]["value"] = ""; - } - element["columns"][5]["font"] = "SANSSERIF"; + LLScrollListCell::Params cell_params; + cell_params.font = LLFontGL::getFontSansSerif(); - list->addElement(element); + cell_params.column = "size"; + cell_params.value = size; + item_params.columns.add(cell_params); + + cell_params.column = "urls"; + cell_params.value = urls; + item_params.columns.add(cell_params); + + cell_params.column = "name"; + cell_params.value = name_buf; + item_params.columns.add(cell_params); + + cell_params.column = "owner"; + cell_params.value = owner_buf; + item_params.columns.add(cell_params); + + cell_params.column = "parcel"; + cell_params.value = parcel_name; + item_params.columns.add(cell_params); + + cell_params.column = "location"; + cell_params.value = has_locations + ? llformat("<%0.1f,%0.1f,%0.1f>", location_x, location_y, location_z) + : ""; + item_params.columns.add(cell_params); + + list->addRow(item_params); + LLSD element; element["owner_id"] = owner_id; + + element["id"] = task_id; element["local_id"] = local_id; mObjectListItems.push_back(element); } -- cgit v1.2.3 From 9609b2c81c1efc43c152e379ca56191c7295973a Mon Sep 17 00:00:00 2001 From: Richard Nelson Date: Fri, 6 Aug 2010 11:03:15 -0700 Subject: renamed LLFastXUIParser to LLSimpleXUIParser and added support for parsing xml node text contents --- indra/llui/lluictrlfactory.cpp | 2 +- indra/llxuixml/llxuiparser.cpp | 108 ++++++++++++++++++++++------------------- indra/llxuixml/llxuiparser.h | 23 +++++++-- 3 files changed, 78 insertions(+), 55 deletions(-) (limited to 'indra') diff --git a/indra/llui/lluictrlfactory.cpp b/indra/llui/lluictrlfactory.cpp index 6ad104c1f4..c5bd6c7fce 100644 --- a/indra/llui/lluictrlfactory.cpp +++ b/indra/llui/lluictrlfactory.cpp @@ -103,7 +103,7 @@ void LLUICtrlFactory::loadWidgetTemplate(const std::string& widget_tag, LLInitPa if (!full_filename.empty()) { LLUICtrlFactory::instance().pushFileName(full_filename); - LLFastXUIParser::instance().readXUI(full_filename, block); + LLSimpleXUIParser::instance().readXUI(full_filename, block); LLUICtrlFactory::instance().popFileName(); } } diff --git a/indra/llxuixml/llxuiparser.cpp b/indra/llxuixml/llxuiparser.cpp index 00128c978a..e010b4c125 100644 --- a/indra/llxuixml/llxuiparser.cpp +++ b/indra/llxuixml/llxuiparser.cpp @@ -976,7 +976,7 @@ void LLXUIParser::parserError(const std::string& message) // -// LLFastXUIParser +// LLSimpleXUIParser // struct ScopedFile @@ -1008,7 +1008,7 @@ struct ScopedFile LLFILE* mFile; }; -LLFastXUIParser::LLFastXUIParser() +LLSimpleXUIParser::LLSimpleXUIParser() : mLastWriteGeneration(-1), mCurReadDepth(0) { @@ -1028,19 +1028,19 @@ LLFastXUIParser::LLFastXUIParser() registerParserFuncs(readSDValue, NULL); } -LLFastXUIParser::~LLFastXUIParser() +LLSimpleXUIParser::~LLSimpleXUIParser() { } -bool LLFastXUIParser::readXUI(const std::string& filename, LLInitParam::BaseBlock& block, bool silent) +bool LLSimpleXUIParser::readXUI(const std::string& filename, LLInitParam::BaseBlock& block, bool silent) { LLFastTimer timer(FTM_PARSE_XUI); mParser = XML_ParserCreate(NULL); XML_SetUserData(mParser, this); - XML_SetElementHandler( mParser, startElementHandler, endElementHandler); - XML_SetCharacterDataHandler( mParser, characterDataHandler); + XML_SetElementHandler( mParser, startElementHandler, endElementHandler); + XML_SetCharacterDataHandler( mParser, characterDataHandler); mBlock = █ mNameStack.clear(); @@ -1085,25 +1085,25 @@ bool LLFastXUIParser::readXUI(const std::string& filename, LLInitParam::BaseBloc return true; } -void LLFastXUIParser::startElementHandler(void *userData, const char *name, const char **atts) +void LLSimpleXUIParser::startElementHandler(void *userData, const char *name, const char **atts) { - LLFastXUIParser* self = reinterpret_cast(userData); + LLSimpleXUIParser* self = reinterpret_cast(userData); self->startElement(name, atts); } -void LLFastXUIParser::endElementHandler(void *userData, const char *name) +void LLSimpleXUIParser::endElementHandler(void *userData, const char *name) { - LLFastXUIParser* self = reinterpret_cast(userData); + LLSimpleXUIParser* self = reinterpret_cast(userData); self->endElement(name); } -void LLFastXUIParser::characterDataHandler(void *userData, const char *s, int len) +void LLSimpleXUIParser::characterDataHandler(void *userData, const char *s, int len) { - LLFastXUIParser* self = reinterpret_cast(userData); + LLSimpleXUIParser* self = reinterpret_cast(userData); self->characterData(s, len); } -void LLFastXUIParser::startElement(const char *name, const char **atts) +void LLSimpleXUIParser::startElement(const char *name, const char **atts) { typedef boost::tokenizer > tokenizer; boost::char_separator sep("."); @@ -1122,6 +1122,7 @@ void LLFastXUIParser::startElement(const char *name, const char **atts) { mNameStack.push_back(std::make_pair(child_name, newParseGeneration())); num_tokens_pushed++; + mScope.push_back(child_name); } else { @@ -1154,14 +1155,14 @@ void LLFastXUIParser::startElement(const char *name, const char **atts) } else { - mScope.push_back(name); + mScope.push_back(child_name); } mTokenSizeStack.push_back(num_tokens_pushed); readAttributes(atts); } -bool LLFastXUIParser::readAttributes(const char **atts) +bool LLSimpleXUIParser::readAttributes(const char **atts) { typedef boost::tokenizer > tokenizer; boost::char_separator sep("."); @@ -1194,8 +1195,16 @@ bool LLFastXUIParser::readAttributes(const char **atts) } -void LLFastXUIParser::endElement(const char *name) +void LLSimpleXUIParser::endElement(const char *name) { + if (!mTextContents.empty()) + { + mNameStack.push_back(std::make_pair(std::string("value"), newParseGeneration())); + mCurAttributeValueBegin = mTextContents.c_str(); + mBlock->submitValue(mNameStack, *this); + mNameStack.pop_back(); + mTextContents.clear(); + } mCurReadDepth--; S32 num_tokens_to_pop = mTokenSizeStack.back(); mTokenSizeStack.pop_back(); @@ -1206,12 +1215,13 @@ void LLFastXUIParser::endElement(const char *name) mScope.pop_back(); } -void LLFastXUIParser::characterData(const char *s, int len) +void LLSimpleXUIParser::characterData(const char *s, int len) { + mTextContents += std::string(s, len); } -/*virtual*/ std::string LLFastXUIParser::getCurrentElementName() +/*virtual*/ std::string LLSimpleXUIParser::getCurrentElementName() { std::string full_name; for (name_stack_t::iterator it = mNameStack.begin(); @@ -1226,7 +1236,7 @@ void LLFastXUIParser::characterData(const char *s, int len) const S32 LINE_NUMBER_HERE = 0; -void LLFastXUIParser::parserWarning(const std::string& message) +void LLSimpleXUIParser::parserWarning(const std::string& message) { #ifdef LL_WINDOWS // use Visual Studo friendly formatting of output message for easy access to originating xml @@ -1238,7 +1248,7 @@ void LLFastXUIParser::parserWarning(const std::string& message) #endif } -void LLFastXUIParser::parserError(const std::string& message) +void LLSimpleXUIParser::parserError(const std::string& message) { #ifdef LL_WINDOWS llutf16string utf16str = utf8str_to_utf16str(llformat("%s(%d):\t%s", mCurFileName.c_str(), LINE_NUMBER_HERE, message.c_str()).c_str()); @@ -1249,9 +1259,9 @@ void LLFastXUIParser::parserError(const std::string& message) #endif } -bool LLFastXUIParser::readBoolValue(Parser& parser, void* val_ptr) +bool LLSimpleXUIParser::readBoolValue(Parser& parser, void* val_ptr) { - LLFastXUIParser& self = static_cast(parser); + LLSimpleXUIParser& self = static_cast(parser); if (!strcmp(self.mCurAttributeValueBegin, "true")) { *((bool*)val_ptr) = true; @@ -1266,64 +1276,64 @@ bool LLFastXUIParser::readBoolValue(Parser& parser, void* val_ptr) return false; } -bool LLFastXUIParser::readStringValue(Parser& parser, void* val_ptr) +bool LLSimpleXUIParser::readStringValue(Parser& parser, void* val_ptr) { - LLFastXUIParser& self = static_cast(parser); + LLSimpleXUIParser& self = static_cast(parser); *((std::string*)val_ptr) = self.mCurAttributeValueBegin; return true; } -bool LLFastXUIParser::readU8Value(Parser& parser, void* val_ptr) +bool LLSimpleXUIParser::readU8Value(Parser& parser, void* val_ptr) { - LLFastXUIParser& self = static_cast(parser); + LLSimpleXUIParser& self = static_cast(parser); return parse(self.mCurAttributeValueBegin, uint_p[assign_a(*(U8*)val_ptr)]).full; } -bool LLFastXUIParser::readS8Value(Parser& parser, void* val_ptr) +bool LLSimpleXUIParser::readS8Value(Parser& parser, void* val_ptr) { - LLFastXUIParser& self = static_cast(parser); + LLSimpleXUIParser& self = static_cast(parser); return parse(self.mCurAttributeValueBegin, int_p[assign_a(*(S8*)val_ptr)]).full; } -bool LLFastXUIParser::readU16Value(Parser& parser, void* val_ptr) +bool LLSimpleXUIParser::readU16Value(Parser& parser, void* val_ptr) { - LLFastXUIParser& self = static_cast(parser); + LLSimpleXUIParser& self = static_cast(parser); return parse(self.mCurAttributeValueBegin, uint_p[assign_a(*(U16*)val_ptr)]).full; } -bool LLFastXUIParser::readS16Value(Parser& parser, void* val_ptr) +bool LLSimpleXUIParser::readS16Value(Parser& parser, void* val_ptr) { - LLFastXUIParser& self = static_cast(parser); + LLSimpleXUIParser& self = static_cast(parser); return parse(self.mCurAttributeValueBegin, int_p[assign_a(*(S16*)val_ptr)]).full; } -bool LLFastXUIParser::readU32Value(Parser& parser, void* val_ptr) +bool LLSimpleXUIParser::readU32Value(Parser& parser, void* val_ptr) { - LLFastXUIParser& self = static_cast(parser); + LLSimpleXUIParser& self = static_cast(parser); return parse(self.mCurAttributeValueBegin, uint_p[assign_a(*(U32*)val_ptr)]).full; } -bool LLFastXUIParser::readS32Value(Parser& parser, void* val_ptr) +bool LLSimpleXUIParser::readS32Value(Parser& parser, void* val_ptr) { - LLFastXUIParser& self = static_cast(parser); + LLSimpleXUIParser& self = static_cast(parser); return parse(self.mCurAttributeValueBegin, int_p[assign_a(*(S32*)val_ptr)]).full; } -bool LLFastXUIParser::readF32Value(Parser& parser, void* val_ptr) +bool LLSimpleXUIParser::readF32Value(Parser& parser, void* val_ptr) { - LLFastXUIParser& self = static_cast(parser); + LLSimpleXUIParser& self = static_cast(parser); return parse(self.mCurAttributeValueBegin, real_p[assign_a(*(F32*)val_ptr)]).full; } -bool LLFastXUIParser::readF64Value(Parser& parser, void* val_ptr) +bool LLSimpleXUIParser::readF64Value(Parser& parser, void* val_ptr) { - LLFastXUIParser& self = static_cast(parser); + LLSimpleXUIParser& self = static_cast(parser); return parse(self.mCurAttributeValueBegin, real_p[assign_a(*(F64*)val_ptr)]).full; } -bool LLFastXUIParser::readColor4Value(Parser& parser, void* val_ptr) +bool LLSimpleXUIParser::readColor4Value(Parser& parser, void* val_ptr) { - LLFastXUIParser& self = static_cast(parser); + LLSimpleXUIParser& self = static_cast(parser); LLColor4 value; if (parse(self.mCurAttributeValueBegin, real_p[assign_a(value.mV[0])] >> real_p[assign_a(value.mV[1])] >> real_p[assign_a(value.mV[2])] >> real_p[assign_a(value.mV[3])], space_p).full) @@ -1334,9 +1344,9 @@ bool LLFastXUIParser::readColor4Value(Parser& parser, void* val_ptr) return false; } -bool LLFastXUIParser::readUIColorValue(Parser& parser, void* val_ptr) +bool LLSimpleXUIParser::readUIColorValue(Parser& parser, void* val_ptr) { - LLFastXUIParser& self = static_cast(parser); + LLSimpleXUIParser& self = static_cast(parser); LLColor4 value; LLUIColor* colorp = (LLUIColor*)val_ptr; @@ -1348,12 +1358,12 @@ bool LLFastXUIParser::readUIColorValue(Parser& parser, void* val_ptr) return false; } -bool LLFastXUIParser::readUUIDValue(Parser& parser, void* val_ptr) +bool LLSimpleXUIParser::readUUIDValue(Parser& parser, void* val_ptr) { - LLFastXUIParser& self = static_cast(parser); + LLSimpleXUIParser& self = static_cast(parser); LLUUID temp_id; // LLUUID::set is destructive, so use temporary value - if (temp_id.set(self.mCurAttributeValueBegin)) + if (temp_id.set(std::string(self.mCurAttributeValueBegin))) { *(LLUUID*)(val_ptr) = temp_id; return true; @@ -1361,9 +1371,9 @@ bool LLFastXUIParser::readUUIDValue(Parser& parser, void* val_ptr) return false; } -bool LLFastXUIParser::readSDValue(Parser& parser, void* val_ptr) +bool LLSimpleXUIParser::readSDValue(Parser& parser, void* val_ptr) { - LLFastXUIParser& self = static_cast(parser); + LLSimpleXUIParser& self = static_cast(parser); *((LLSD*)val_ptr) = LLSD(self.mCurAttributeValueBegin); return true; } \ No newline at end of file diff --git a/indra/llxuixml/llxuiparser.h b/indra/llxuixml/llxuiparser.h index 4deb083e1c..eb7147f49e 100644 --- a/indra/llxuixml/llxuiparser.h +++ b/indra/llxuixml/llxuiparser.h @@ -171,14 +171,25 @@ private: std::string mCurFileName; }; -class LLFastXUIParser : public LLInitParam::Parser, public LLSingleton +// LLSimpleXUIParser is a streamlined SAX-based XUI parser that does not support localization +// or parsing of a tree of independent param blocks, such as child widgets. +// Use this for reading non-localized files that only need a single param block as a result. +// +// NOTE: In order to support nested block parsing, we need callbacks for start element that +// push new blocks contexts on the mScope stack. +// NOTE: To support localization without building a DOM, we need to enforce consistent +// ordering of child elements from base file to localized diff file. Then we can use a pair +// of coroutines to perform matching of xml nodes during parsing. Not sure if the overhead +// of coroutines would offset the gain from SAX parsing + +class LLSimpleXUIParser : public LLInitParam::Parser, public LLSingleton { -LOG_CLASS(LLFastXUIParser); +LOG_CLASS(LLSimpleXUIParser); protected: - LLFastXUIParser(); - virtual ~LLFastXUIParser(); - friend class LLSingleton; + LLSimpleXUIParser(); + virtual ~LLSimpleXUIParser(); + friend class LLSingleton; public: typedef LLInitParam::Parser::name_stack_t name_stack_t; @@ -187,6 +198,7 @@ public: /*virtual*/ void parserError(const std::string& message); bool readXUI(const std::string& filename, LLInitParam::BaseBlock& block, bool silent=false); + void setBlock(LLInitParam::BaseBlock* block); private: //reader helper functions @@ -222,6 +234,7 @@ private: LLXMLNodePtr mLastWrittenChild; S32 mCurReadDepth; std::string mCurFileName; + std::string mTextContents; const char* mCurAttributeValueBegin; std::vector mTokenSizeStack; std::vector mScope; -- cgit v1.2.3 From 5866710be7b64999ec82c5cd5e2d47d81fdeb918 Mon Sep 17 00:00:00 2001 From: Richard Nelson Date: Fri, 6 Aug 2010 11:03:28 -0700 Subject: fixed crash on entering build mode --- indra/llrender/llrender.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra') diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index 64238b2008..eb2c54198d 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -901,7 +901,7 @@ LLVector3 LLRender::getUITranslation() { if (mUIOffset.empty()) { - llerrs << "UI offset stack empty." << llendl; + return LLVector3::zero; } return mUIOffset.back(); } @@ -910,7 +910,7 @@ LLVector3 LLRender::getUIScale() { if (mUIScale.empty()) { - llerrs << "UI scale stack empty." << llendl; + return LLVector3(1.f, 1.f, 1.f); } return mUIScale.back(); } -- cgit v1.2.3 From 7b41819377ec1c6ffc835a0a05a1acf571f46aad Mon Sep 17 00:00:00 2001 From: Richard Nelson Date: Fri, 6 Aug 2010 11:49:43 -0700 Subject: removed spurious parsing of empty text contents --- indra/llxuixml/llxuiparser.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'indra') diff --git a/indra/llxuixml/llxuiparser.cpp b/indra/llxuixml/llxuiparser.cpp index e010b4c125..b3cb71cd61 100644 --- a/indra/llxuixml/llxuiparser.cpp +++ b/indra/llxuixml/llxuiparser.cpp @@ -1199,11 +1199,15 @@ void LLSimpleXUIParser::endElement(const char *name) { if (!mTextContents.empty()) { - mNameStack.push_back(std::make_pair(std::string("value"), newParseGeneration())); - mCurAttributeValueBegin = mTextContents.c_str(); - mBlock->submitValue(mNameStack, *this); - mNameStack.pop_back(); - mTextContents.clear(); + LLStringUtil::trim(mTextContents); + if (!mTextContents.empty()) + { + mNameStack.push_back(std::make_pair(std::string("value"), newParseGeneration())); + mCurAttributeValueBegin = mTextContents.c_str(); + mBlock->submitValue(mNameStack, *this, false); + mNameStack.pop_back(); + mTextContents.clear(); + } } mCurReadDepth--; S32 num_tokens_to_pop = mTokenSizeStack.back(); -- cgit v1.2.3