From acb770909e4c04e96606eef47df3a485fc3ca51d Mon Sep 17 00:00:00 2001 From: ispyisail Date: Sun, 27 Sep 2026 11:16:37 +1300 Subject: [PATCH] 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 --- sources/diagramposition.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sources/diagramposition.cpp b/sources/diagramposition.cpp index 965610fc1..c133b5412 100644 --- a/sources/diagramposition.cpp +++ b/sources/diagramposition.cpp @@ -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; }