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.
This commit is contained in:
@@ -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();
|
||||
}
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user