MachOObjectFile - checkOverlappingElement - use const-ref to avoid unnecessary copies. NFCI.

Reported by MSVC static analyzer.
This commit is contained in:
Simon Pilgrim 2021-09-17 17:47:28 +01:00
parent 4ab7c0d3fa
commit 7fc12b822c
1 changed files with 3 additions and 3 deletions

View File

@ -246,8 +246,8 @@ static Error checkOverlappingElement(std::list<MachOElement> &Elements,
if (Size == 0)
return Error::success();
for (auto it=Elements.begin() ; it != Elements.end(); ++it) {
auto E = *it;
for (auto it = Elements.begin(); it != Elements.end(); ++it) {
const auto &E = *it;
if ((Offset >= E.Offset && Offset < E.Offset + E.Size) ||
(Offset + Size > E.Offset && Offset + Size < E.Offset + E.Size) ||
(Offset <= E.Offset && Offset + Size >= E.Offset + E.Size))
@ -258,7 +258,7 @@ static Error checkOverlappingElement(std::list<MachOElement> &Elements,
auto nt = it;
nt++;
if (nt != Elements.end()) {
auto N = *nt;
const auto &N = *nt;
if (Offset + Size <= N.Offset) {
Elements.insert(nt, {Offset, Size, Name});
return Error::success();