mirror of
https://github.com/serge1/ELFIO.git
synced 2025-01-30 06:32:43 +00:00
Refactoring - a nicer code for is_subsequence_of()
Conflicts: elf_examples/asm_copy
This commit is contained in:
parent
a88cfacaca
commit
1db119a8ca
@ -484,19 +484,19 @@ class elfio
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool is_subsequence_of( segment* seg1, segment* seg2 )
|
||||
{
|
||||
// Return 'true' if sections of seg1 are a subset of sections in seg2
|
||||
const std::vector<Elf_Half>& sections1 = seg1->get_sections();
|
||||
const std::vector<Elf_Half>& sections2 = seg2->get_sections();
|
||||
|
||||
bool found = std::search( sections2.begin(), sections2.end(),
|
||||
sections1.begin(), sections1.end() )
|
||||
!= sections2.end();
|
||||
|
||||
return found &&
|
||||
( sections2.size() != 0 ) &&
|
||||
( sections1.size() != sections2.size() );
|
||||
bool is_subsequence_of( segment* seg1, segment* seg2 )
|
||||
{
|
||||
// Return 'true' if sections of seg1 are a subset of sections in seg2
|
||||
const std::vector<Elf_Half>& sections1 = seg1->get_sections();
|
||||
const std::vector<Elf_Half>& sections2 = seg2->get_sections();
|
||||
|
||||
bool found = false;
|
||||
if ( sections1.size() < sections2.size() ) {
|
||||
found = std::includes( sections2.begin(), sections2.end(),
|
||||
sections1.begin(), sections1.end() );
|
||||
}
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
Loading…
x
Reference in New Issue
Block a user