qetproject: memoize repeated numbering title/id lookups per call

elementAutoNumIdToLink() queried numbering_scheme per symbol even when
many symbols on unbuilt folios share the same scheme; setUpFormula()
fetched the same scheme's rows twice (elementAutoNumCurrentFormula()
then elementAutoNum() separately). Both are real but didn't resolve
the tst_lazyfolios ASan timeout on their own -- see QETZ-DB-FIRST-PLAN.md's
2b-3 row for the remaining open question.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
ispyisail
2026-10-21 10:46:34 +13:00
parent 122678a797
commit e7d644003f
3 changed files with 49 additions and 16 deletions
+9 -10
View File
@@ -2568,21 +2568,20 @@ void Element::setUpFormula(bool code_letter, QUndoCommand *parent_undo)
if (diagram())
{
QString formula = diagram()
->project()
->elementAutoNumCurrentFormula();
QETProject *autonum_project = diagram()->project();
QString element_currentAutoNum = autonum_project->elementCurrentAutoNum();
//One query for the scheme's rows, read once and reused below --
//elementAutoNumCurrentFormula()+elementAutoNum() each re-fetched
//the same rows separately (2b-3: every numbering read is now a
//database query, so a second fetch is a second round trip).
NumerotationContext nc = autonum_project->elementAutoNum(element_currentAutoNum);
QString formula = autonum::numerotationContextToFormula(nc);
m_data.m_informations.addValue(QStringLiteral("formula"), formula);
storeInformation();
QString element_currentAutoNum = diagram()
->project()
->elementCurrentAutoNum();
const QUuid scheme_id = diagram()->project()->elementAutoNumId(element_currentAutoNum);
const QUuid scheme_id = autonum_project->elementAutoNumId(element_currentAutoNum);
setFormulaSchemeId(formula.isEmpty() ? QUuid() : scheme_id);
NumerotationContext nc = diagram()
->project()
->elementAutoNum(element_currentAutoNum);
//The number given is the first whose label no other element of
//the project carries: a counter set back, or an element which