Refactoring - a nicer code for is_subsequence_of()

Conflicts:
	elf_examples/asm_copy
This commit is contained in:
Serge Lamikhov-Center 2014-11-12 18:36:18 +02:00
parent a88cfacaca
commit 1db119a8ca

View File

@ -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;
}
//------------------------------------------------------------------------------