summaryrefslogtreecommitdiff
path: root/src/ReplayGainInfo.hxx
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2016-11-24 16:45:56 +0100
committerMax Kellermann <max@musicpd.org>2016-11-24 17:34:57 +0100
commit25e58df5e07c3eb878d48ac58780d56f2ecdd565 (patch)
tree63fb6dfff4c8a96eb17adcdb263f0b6fe769094c /src/ReplayGainInfo.hxx
parent1261327fa61fbf01adaab639bb012dae58ddab1a (diff)
ReplayGainInfo: don't use array in struct ReplayGainInfo
Declare two named elements. An enum should not be used as an array index, as this is error prone.
Diffstat (limited to 'src/ReplayGainInfo.hxx')
-rw-r--r--src/ReplayGainInfo.hxx17
1 files changed, 6 insertions, 11 deletions
diff --git a/src/ReplayGainInfo.hxx b/src/ReplayGainInfo.hxx
index 432171b3f..18e21604d 100644
--- a/src/ReplayGainInfo.hxx
+++ b/src/ReplayGainInfo.hxx
@@ -49,26 +49,21 @@ struct ReplayGainTuple {
};
struct ReplayGainInfo {
- ReplayGainTuple tuples[2];
+ ReplayGainTuple track, album;
constexpr bool IsDefined() const {
- return tuples[REPLAY_GAIN_ALBUM].IsDefined() ||
- tuples[REPLAY_GAIN_TRACK].IsDefined();
+ return track.IsDefined() || album.IsDefined();
}
const ReplayGainTuple &Get(ReplayGainMode mode) const {
return mode == REPLAY_GAIN_ALBUM
- ? (tuples[REPLAY_GAIN_ALBUM].IsDefined()
- ? tuples[REPLAY_GAIN_ALBUM]
- : tuples[REPLAY_GAIN_TRACK])
- : (tuples[REPLAY_GAIN_TRACK].IsDefined()
- ? tuples[REPLAY_GAIN_TRACK]
- : tuples[REPLAY_GAIN_ALBUM]);
+ ? (album.IsDefined() ? album : track)
+ : (track.IsDefined() ? track : album);
}
void Clear() {
- tuples[REPLAY_GAIN_ALBUM].Clear();
- tuples[REPLAY_GAIN_TRACK].Clear();
+ track.Clear();
+ album.Clear();
}
};