Skip to content

Commit

Permalink
[musicxml] Replaced QHash with std::unordered_map
Browse files Browse the repository at this point in the history
Backport of musescore#21400, part 1, partly
  • Loading branch information
igorkorsukov authored and Jojo-Schmitz committed Apr 10, 2024
1 parent 34bc575 commit f94d7f2
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions importexport/musicxml/exportxml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -1005,8 +1003,8 @@ static void findTrills(const Measure* const measure, int strack, int etrack, Tri
auto 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 });
}
}
}
Expand Down Expand Up @@ -2621,11 +2619,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 auto tr = trillStart.value(cr);
if (mu::contains(trillStart, cr) && mu::contains(trillStop, cr)) {
const auto tr = trillStart.at(cr);
auto n = findTrill(0);
if (n >= 0) {
wavyLineStart(tr, n, notations, ornaments, _xml);
Expand All @@ -2636,8 +2634,8 @@ void ExportMusicXml::wavyLineStartStop(const ChordRest* const cr, Notations& not
cr, cr->staffIdx(), cr->tick().ticks());
}
else {
if (trillStop.contains(cr)) {
const auto tr = trillStop.value(cr);
if (mu::contains(trillStop, cr)) {
const auto tr = trillStop.at(cr);
auto n = findTrill(tr);
if (n >= 0)
// trill stop after trill start
Expand All @@ -2654,10 +2652,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 auto tr = trillStart.value(cr);
if (mu::contains(trillStart, cr)) {
const auto tr = trillStart.at(cr);
auto n = findTrill(tr);
if (n >= 0)
qDebug("wavyLineStartStop error");
Expand All @@ -2670,7 +2668,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);
}
}
}
Expand Down

0 comments on commit f94d7f2

Please sign in to comment.