@@ -489,58 +489,70 @@ bool LLPanel::initPanelXML(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr outpu
489489 LL_RECORD_BLOCK_TIME (FTM_PANEL_SETUP);
490490
491491 LLXMLNodePtr referenced_xml;
492- std::string xml_filename = mXMLFilename ;
492+ const std::string& xml_filename = mXMLFilename ;
493493
494494 // if the panel didn't provide a filename, check the node
495495 if (xml_filename.empty ())
496496 {
497- node->getAttributeString (" filename" , xml_filename);
498- setXMLFilename (xml_filename);
497+ std::string temp_filename;
498+ node->getAttributeString (" filename" , temp_filename);
499+ setXMLFilename (temp_filename);
499500 }
500501
502+ // Cache singleton and filename to avoid repeated calls
503+ LLUICtrlFactory* factory = LLUICtrlFactory::getInstance ();
504+
505+ // Cache node name pointer to avoid repeated dereferencing
506+ const LLStringTableEntry* node_name = node->getName ();
507+
508+ // Cache registry to avoid repeated singleton access
509+ const child_registry_t & registry = child_registry_t::instance ();
510+
501511 LLXUIParser parser;
502512
503- if (!xml_filename .empty ())
513+ if (!mXMLFilename .empty ())
504514 {
505515 if (output_node)
506516 {
507517 // if we are exporting, we want to export the current xml
508518 // not the referenced xml
509- parser.readXUI (node, params, LLUICtrlFactory::getInstance () ->getCurFileName ());
519+ parser.readXUI (node, params, factory ->getCurFileName ());
510520 Params output_params (params);
511521 setupParamsForExport (output_params, parent);
512- output_node->setName (node-> getName () ->mString );
522+ output_node->setName (node_name ->mString );
513523 parser.writeXUI (output_node, output_params, LLInitParam::default_parse_rules (), &default_params);
514524 return true ;
515525 }
516526
517- LLUICtrlFactory::instance (). pushFileName (xml_filename );
527+ factory-> pushFileName (mXMLFilename );
518528
519529 LL_RECORD_BLOCK_TIME (FTM_EXTERNAL_PANEL_LOAD);
520- if (!LLUICtrlFactory::getLayeredXMLNode (xml_filename , referenced_xml))
530+ if (!LLUICtrlFactory::getLayeredXMLNode (mXMLFilename , referenced_xml))
521531 {
522- LL_WARNS () << " Couldn't parse panel from: " << xml_filename << LL_ENDL;
532+ LL_WARNS () << " Couldn't parse panel from: " << mXMLFilename << LL_ENDL;
523533
524534 return false ;
525535 }
526536
527- parser.readXUI (referenced_xml, params, LLUICtrlFactory::getInstance ()->getCurFileName ());
537+ // Get filename after pushFileName
538+ const std::string& updated_filename = factory->getCurFileName ();
539+ parser.readXUI (referenced_xml, params, updated_filename);
528540
529541 // add children using dimensions from referenced xml for consistent layout
530542 setShape (params.rect );
531- LLUICtrlFactory::createChildren (this , referenced_xml, child_registry_t::instance () );
543+ LLUICtrlFactory::createChildren (this , referenced_xml, registry );
532544
533- LLUICtrlFactory::instance (). popFileName ();
545+ factory-> popFileName ();
534546 }
535547
536548 // ask LLUICtrlFactory for filename, since xml_filename might be empty
537- parser.readXUI (node, params, LLUICtrlFactory::getInstance () ->getCurFileName ());
549+ parser.readXUI (node, params, factory ->getCurFileName ());
538550
539551 if (output_node)
540552 {
541553 Params output_params (params);
542554 setupParamsForExport (output_params, parent);
543- output_node->setName (node-> getName () ->mString );
555+ output_node->setName (node_name ->mString );
544556 parser.writeXUI (output_node, output_params, LLInitParam::default_parse_rules (), &default_params);
545557 }
546558
@@ -552,7 +564,7 @@ bool LLPanel::initPanelXML(LLXMLNodePtr node, LLView *parent, LLXMLNodePtr outpu
552564 }
553565
554566 // add children
555- LLUICtrlFactory::createChildren (this , node, child_registry_t::instance () , output_node);
567+ LLUICtrlFactory::createChildren (this , node, registry , output_node);
556568
557569 // Connect to parent after children are built, because tab containers
558570 // do a reshape() on their child panels, which requires that the children
0 commit comments