Skip to content

Commit 71e99c5

Browse files
committed
Simplify ordering code as suggested in PR comments.
1 parent a1eab1c commit 71e99c5

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/patchelf.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,12 @@ class ElfFile
135135
ElfFile * elfFile;
136136
bool operator ()(const Elf_Phdr & x, const Elf_Phdr & y)
137137
{
138-
if (x.p_type == PT_PHDR) {
139-
if (y.p_type == PT_PHDR) return false;
140-
return true;
141-
}
142-
if (y.p_type == PT_PHDR) return false;
143-
return elfFile->rdi(x.p_paddr) < elfFile->rdi(y.p_paddr);
138+
// A PHDR comes before everything else.
139+
if (y.p_type == PT_PHDR) return false;
140+
if (x.p_type == PT_PHDR) return true;
141+
142+
// Sort non-PHDRs by address.
143+
return elfFile->rdi(x.p_paddr) < elfFile->rdi(y.p_paddr);
144144
}
145145
};
146146

0 commit comments

Comments
 (0)