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 May 6, 2024
1 parent 01acd8b commit e25978c
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
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 });
}
}
}
Expand Down Expand Up @@ -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);
Expand All @@ -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
Expand All @@ -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");
Expand All @@ -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);
}
}
}
Expand Down

0 comments on commit e25978c

Please sign in to comment.