DiagramPosition: compile the letter filter once

The constructor built QRegularExpression("[^A-Z]") on every call, and
compiling it cost more than the rest of Diagram::convertPosition() put
together -- about 95k instructions a call under callgrind. Every element
row of the project database pays it on each rebuild, as does anything
else that turns a scene point into a folio cell.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ispyisail
2026-09-27 11:16:37 +13:00
parent a9ad6e2f34
commit acb770909e
+5 -1
View File
@@ -29,7 +29,11 @@
DiagramPosition::DiagramPosition(const QString &letter, unsigned int number) {
// purifie les lettres
letter_ = letter.toUpper();
letter_.remove(QRegularExpression("[^A-Z]"));
//Compiled once: building it here cost more than the rest of the
//position conversion together, once per element and per drawing item
//on every rebuild of the project database.
static const QRegularExpression not_a_letter(QStringLiteral("[^A-Z]"));
letter_.remove(not_a_letter);
number_ = number;
}