Skip to content

Commit

Permalink
Use operator[] instead of .at() for asFeatureStats element access
Browse files Browse the repository at this point in the history
Don't use `.at()` method, which performs additional
bounds checking in cases where we know upfront
that the element exists.

Signed-off-by: Pavel Solodovnikov <[email protected]>
  • Loading branch information
ManManson authored and past-due committed Jan 8, 2024
1 parent 6b55a21 commit e40b8ee
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/feature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ bool loadFeatureStats(WzConfig &ini)
{
ini.beginGroup(list[i]);
asFeatureStats.emplace_back(STAT_FEATURE + i);
FEATURE_STATS& p = asFeatureStats.at(i);
FEATURE_STATS& p = asFeatureStats[i];
p.name = ini.string(WzString::fromUtf8("name"));
p.id = list[i];
WzString subType = ini.value("type").toWzString();
Expand Down
2 changes: 1 addition & 1 deletion src/hci.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1272,7 +1272,7 @@ void intOpenDebugMenu(OBJECT_TYPE id)
case OBJ_FEATURE:
for (unsigned i = 0, end = std::min<unsigned>(asFeatureStats.size(), MAXFEATURES); i < end; ++i)
{
apsFeatureList[i] = &asFeatureStats.at(i);
apsFeatureList[i] = &asFeatureStats[i];
}
ppsStatsList = (BASE_STATS **)apsFeatureList;
intAddDebugStatsForm(ppsStatsList, std::min<unsigned>(asFeatureStats.size(), MAXFEATURES));
Expand Down

0 comments on commit e40b8ee

Please sign in to comment.