Use range-based for loops where possible.
--- a/src/in_ncsf/SSEQPlayer/Player.cpp
+++ b/src/in_ncsf/SSEQPlayer/Player.cpp
@@ -73,9 +73,7 @@
{
std::uint8_t trackId = this->trackIds[i];
this->tracks[trackId].ClearState();
- for (int j = 0; j < 16; ++j)
- {
- Channel &chn = this->channels[j];
+ for (auto &chn : this->channels)
if (chn.state != ChannelState::None && chn.trackId == trackId)
{
if (bKillSound)
@@ -83,7 +81,6 @@
else
chn.Release();
}
- }
}
this->FreeTracks();
}
@@ -159,10 +156,10 @@
void Player::UpdateTracks()
{
- for (int i = 0; i < 16; ++i)
- this->channels[i].UpdateTrack();
- for (int i = 0; i < FSS_MAXTRACKS; ++i)
- this->tracks[i].updateFlags.reset();
+ for (auto &chn : this->channels)
+ chn.UpdateTrack();
+ for (auto &trk : this->tracks)
+ trk.updateFlags.reset();
}
// Original FSS Function: Snd_Timer
@@ -170,8 +167,8 @@
{
this->UpdateTracks();
- for (int i = 0; i < 16; ++i)
- this->channels[i].Update();
+ for (auto &chn : this->channels)
+ chn.Update();
this->Run();
}
--- a/src/in_ncsf/SSEQPlayer/Track.cpp
+++ b/src/in_ncsf/SSEQPlayer/Track.cpp
@@ -262,12 +262,9 @@
// Original FSS Function: Track_ReleaseAllNotes
void Track::ReleaseAllNotes()
{
- for (int i = 0; i < 16; ++i)
- {
- Channel &chn = this->ply->channels[i];
+ for (auto &chn : this->ply->channels)
if (chn.state > ChannelState::None && chn.trackId == this->trackId && chn.state != ChannelState::Release)
chn.Release();
- }
}
enum class SSEQCommand
--- a/src/in_ncsf/SSEQPlayer/common.h
+++ b/src/in_ncsf/SSEQPlayer/common.h
@@ -51,8 +51,8 @@
template<typename T> typename std::enable_if_t<std::is_integral_v<T>> ReadLE(std::vector<T> &arr)
{
- for (std::size_t i = 0, len = arr.size(); i < len; ++i)
- arr[i] = this->ReadLE<T>();
+ for (auto &item : arr)
+ item = this->ReadLE<T>();
}
void ReadLE(std::vector<std::uint8_t> &arr)
--- a/src/in_xsf_framework/TagList.cpp
+++ b/src/in_xsf_framework/TagList.cpp
@@ -26,8 +26,8 @@
auto TagList::GetTags() const -> TagsList
{
TagsList allTags;
- for (auto curr = this->tagsOrder.begin(), end = this->tagsOrder.end(); curr != end; ++curr)
- allTags.push_back(*curr + "=" + this->tags.find(*curr)->second);
+ for (auto &curr : this->tagsOrder)
+ allTags.push_back(curr + "=" + this->tags.find(curr)->second);
return allTags;
}
--- a/src/in_xsf_framework/XSFFile.cpp
+++ b/src/in_xsf_framework/XSFFile.cpp
@@ -166,9 +166,8 @@
xSF.read(&rawtags[0], lengthOfTags);
std::string name, value;
bool onName = true;
- for (unsigned x = 0; x < lengthOfTags; ++x)
+ for (auto curr : rawtags)
{
- char curr = rawtags[x];
if (curr == 0x0A)
{
if (!name.empty() && !value.empty())
@@ -449,7 +448,7 @@
if (!allTags.empty())
{
xSF.write("[TAG]", 5);
- std::for_each(allTags.begin(), allTags.end(), [&](const std::string &tag)
+ for (const auto &tag : allTags)
{
xSF.write(tag.c_str(), tag.length());
xSF.write("\n", 1);