Skip to content

Commit

Permalink
Use x.back() instead of x[x.size() - 1]
Browse files Browse the repository at this point in the history
  • Loading branch information
rouault committed Sep 7, 2024
1 parent 81f5ed9 commit fb592bc
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion apps/gdalmdiminfo_lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1222,7 +1222,7 @@ char *GDALMultiDimInfo(GDALDatasetH hDataset,
}
curGroup = std::move(curGroupNew);
}
const char *pszArrayName = aosTokens[aosTokens.size() - 1];
const char *pszArrayName = aosTokens.back();
auto array(curGroup->OpenMDArray(pszArrayName));
if (!array)
{
Expand Down
2 changes: 1 addition & 1 deletion frmts/grib/gribcreatecopy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2250,7 +2250,7 @@ static void WriteAssembledPDS(VSILFILE *fp, const gtemplate *mappds,
else if (nEltSize == 4)
{
GIntBig nBigVal = CPLAtoGIntBig(papszTokens[i]);
anVals[anVals.size() - 1] = static_cast<int>(nBigVal);
anVals.back() = static_cast<int>(nBigVal);
if (nBigVal < 0 || nBigVal > static_cast<GIntBig>(UINT_MAX))
{
CPLError(CE_Warning, CPLE_AppDefined,
Expand Down
2 changes: 1 addition & 1 deletion frmts/nitf/nitfdataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3366,7 +3366,7 @@ int NITFDataset::CheckForRSets(const char *pszNITFFilename,
if (isR0File)
{
osTarget = pszNITFFilename;
osTarget[osTarget.size() - 1] = static_cast<char>('0' + i);
osTarget.back() = static_cast<char>('0' + i);
}
else
osTarget.Printf("%s.r%d", pszNITFFilename, i);
Expand Down
2 changes: 1 addition & 1 deletion frmts/vrt/vrtmultidim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ VRTGroup::GetDimensionFromFullName(const std::string &name,
return nullptr;
}
}
auto poDim(curGroup->GetDimension(aosTokens[aosTokens.size() - 1]));
auto poDim(curGroup->GetDimension(aosTokens.back()));
if (!poDim)
{
if (bEmitError)
Expand Down
2 changes: 1 addition & 1 deletion ogr/ogrsf_frmts/dxf/ogrdxf_leader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1412,7 +1412,7 @@ static void InterpolateSpline(OGRLineString *const poLine,
adfParameters.push_back(dfParameter);
}

const double dfTotalChordLength = adfParameters[adfParameters.size() - 1];
const double dfTotalChordLength = adfParameters.back();

// Start tangent can be worked out from the first chord
DXFTriple oStartTangent(aoDataPoints[1].dfX - aoDataPoints[0].dfX,
Expand Down
4 changes: 2 additions & 2 deletions ogr/ogrsf_frmts/gmlas/ogrgmlasutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ CPLString OGRGMLASTruncateIdentifier(const CPLString &osName,
{
if (nLastTokenSize > nExtra)
{
aosTokens[aosTokens.size() - 1].resize(nLastTokenSize - nExtra);
aosTokens.back().resize(nLastTokenSize - nExtra);
nExtra = 0;
}
}
Expand All @@ -127,7 +127,7 @@ CPLString OGRGMLASTruncateIdentifier(const CPLString &osName,
// than previous ones.
if (nLastTokenSize > 2 * iter->first)
{
aosTokens[aosTokens.size() - 1].resize(nLastTokenSize - 1);
aosTokens.back().resize(nLastTokenSize - 1);
nLastTokenSize--;
bHasDoneSomething = true;
nExtra--;
Expand Down
2 changes: 1 addition & 1 deletion ogr/ogrsf_frmts/hana/ogrhanadatasource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1714,7 +1714,7 @@ OGRHanaDataSource::ICreateLayer(const char *layerNameIn,

layers_.push_back(std::move(layer));

return layers_[layers_.size() - 1].get();
return layers_.back().get();
}

/************************************************************************/
Expand Down
2 changes: 1 addition & 1 deletion ogr/ogrsf_frmts/plscenes/ogrplscenesdatav1dataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ json_object *OGRPLScenesDataV1Dataset::RunRequest(const char *pszURL,
psResult = (CPLHTTPResult *)CPLCalloc(1, sizeof(CPLHTTPResult));
vsi_l_offset nDataLengthLarge = 0;
CPLString osURL(pszURL);
if (osURL[osURL.size() - 1] == '/')
if (osURL.back() == '/')
osURL.pop_back();
if (pszPostContent != nullptr)
{
Expand Down

0 comments on commit fb592bc

Please sign in to comment.