From e25978c083f423e96e75b2beda28407b9fb565a1 Mon Sep 17 00:00:00 2001
From: Igor Korsukov <igor.korsukov@gmail.com>
Date: Wed, 7 Feb 2024 18:00:42 +0100
Subject: [PATCH] [musicxml] Replaced QHash with std::unordered_map

Backport of #21400, part 1, partly
---
 importexport/musicxml/exportxml.cpp | 30 ++++++++++++++---------------
 1 file changed, 14 insertions(+), 16 deletions(-)

diff --git a/importexport/musicxml/exportxml.cpp b/importexport/musicxml/exportxml.cpp
index b3621d04090ce..da0d1ccbbdf5a 100644
--- a/importexport/musicxml/exportxml.cpp
+++ b/importexport/musicxml/exportxml.cpp
@@ -313,7 +313,7 @@ struct MeasurePrintContext final
 //   ExportMusicXml
 //---------------------------------------------------------
 
-typedef QHash<const ChordRest* const, const Trill*> TrillHash;
+typedef std::unordered_map<const ChordRest*, const Trill*> TrillHash;
 typedef std::map<const Instrument*, int> MxmlInstrumentMap;
 
 class ExportMusicXml {
@@ -354,10 +354,8 @@ class ExportMusicXml {
       void calcDivMoveToTick(const Fraction& t);
       void calcDivisions();
       void keysigTimesig(const Measure* m, const Part* p);
-      void chordAttributes(Chord* chord, Notations& notations, Technical& technical,
-                           TrillHash& trillStart, TrillHash& trillStop);
-      void wavyLineStartStop(const ChordRest* const cr, Notations& notations, Ornaments& ornaments,
-                             TrillHash& trillStart, TrillHash& trillStop);
+      void chordAttributes(Chord* chord, Notations& notations, Technical& technical, TrillHash& trillStart, TrillHash& trillStop);
+      void wavyLineStartStop(const ChordRest* cr, Notations& notations, Ornaments& ornaments, TrillHash& trillStart, TrillHash& trillStop);
       void print(const Measure* const m, const int partNr, const int firstStaffOfPart, const int nrStavesInPart, const MeasurePrintContext& mpc);
       void findAndExportClef(const Measure* const m, const int staves, const int strack, const int etrack);
       void exportDefaultClef(const Part* const part, const Measure* const m);
@@ -1005,8 +1003,8 @@ static void findTrills(const Measure* const measure, int strack, int etrack, Tri
                   Element* elem2 = tr->endElement();
 
                   if (elem1 && elem1->isChordRest() && elem2 && elem2->isChordRest()) {
-                        trillStart.insert(toChordRest(elem1), tr);
-                        trillStop.insert(toChordRest(elem2), tr);
+                        trillStart.insert({ toChordRest(elem1), tr });
+                        trillStop.insert({ toChordRest(elem2), tr });
                         }
                   }
             }
@@ -2630,11 +2628,11 @@ static void wavyLineStop(const Trill* tr, const int number, Notations& notations
 //   wavyLineStartStop
 //---------------------------------------------------------
 
-void ExportMusicXml::wavyLineStartStop(const ChordRest* const cr, Notations& notations, Ornaments& ornaments,
+void ExportMusicXml::wavyLineStartStop(const ChordRest* cr, Notations& notations, Ornaments& ornaments,
                                        TrillHash& trillStart, TrillHash& trillStop)
       {
-      if (trillStart.contains(cr) && trillStop.contains(cr)) {
-            const Trill* tr = trillStart.value(cr);
+      if (mu::contains(trillStart, cr) && mu::contains(trillStop, cr)) {
+            const Trill* tr = trillStart.at(cr);
             int n = findTrill(0);
             if (n >= 0) {
                   wavyLineStart(tr, n, notations, ornaments, _xml);
@@ -2645,8 +2643,8 @@ void ExportMusicXml::wavyLineStartStop(const ChordRest* const cr, Notations& not
                          cr, cr->staffIdx(), cr->tick().ticks());
             }
       else {
-            if (trillStop.contains(cr)) {
-                  const Trill* tr = trillStop.value(cr);
+            if (mu::contains(trillStop, cr)) {
+                  const Trill* tr = trillStop.at(cr);
                   int n = findTrill(tr);
                   if (n >= 0)
                         // trill stop after trill start
@@ -2663,10 +2661,10 @@ void ExportMusicXml::wavyLineStartStop(const ChordRest* const cr, Notations& not
                   if (n >= 0) {
                         wavyLineStop(tr, n, notations, ornaments, _xml);
                         }
-                  trillStop.remove(cr);
+                  mu::remove(trillStop, cr);
                   }
-            if (trillStart.contains(cr)) {
-                  const Trill* tr = trillStart.value(cr);
+            if (mu::contains(trillStart, cr)) {
+                  const Trill* tr = trillStart.at(cr);
                   int n = findTrill(tr);
                   if (n >= 0)
                         qDebug("wavyLineStartStop error");
@@ -2679,7 +2677,7 @@ void ExportMusicXml::wavyLineStartStop(const ChordRest* const cr, Notations& not
                         else
                               qDebug("too many overlapping trills (cr %p staff %d tick %d)",
                                      cr, cr->staffIdx(), cr->tick().ticks());
-                        trillStart.remove(cr);
+                        mu::remove(trillStart, cr);
                         }
                   }
             }