mirror of
https://github.com/dynup/kpatch
synced 2025-05-05 01:17:57 +00:00
improve find_[symbol|section]_by_index
The indexes are in order when being read from the table. Just index directly into the table; a benefit of using an array for this structure instead of a linked list. Removes another hot path during the rela table initialization. Signed-off-by: Seth Jennings <sjenning@redhat.com>
This commit is contained in:
parent
24894d263c
commit
634b9cee78
@ -173,14 +173,9 @@ int is_rela_section(struct section *sec)
|
|||||||
|
|
||||||
struct section *find_section_by_index(struct table *table, unsigned int index)
|
struct section *find_section_by_index(struct table *table, unsigned int index)
|
||||||
{
|
{
|
||||||
struct section *sec;
|
if (index == 0 || index >= table->nr)
|
||||||
int i;
|
|
||||||
|
|
||||||
for_each_section(i, sec, table)
|
|
||||||
if (sec->index == index)
|
|
||||||
return sec;
|
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
return &((struct section *)(table->data))[index-1];
|
||||||
}
|
}
|
||||||
|
|
||||||
struct section *find_section_by_name(struct table *table, const char *name)
|
struct section *find_section_by_name(struct table *table, const char *name)
|
||||||
@ -197,14 +192,9 @@ struct section *find_section_by_name(struct table *table, const char *name)
|
|||||||
|
|
||||||
struct symbol *find_symbol_by_index(struct table *table, size_t index)
|
struct symbol *find_symbol_by_index(struct table *table, size_t index)
|
||||||
{
|
{
|
||||||
struct symbol *sym;
|
if (index >= table->nr)
|
||||||
int i;
|
|
||||||
|
|
||||||
for_each_symbol_zero(i, sym, table)
|
|
||||||
if (sym->index == index)
|
|
||||||
return sym;
|
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
return &((struct symbol *)(table->data))[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
struct symbol *find_symbol_by_name(struct table *table, const char *name)
|
struct symbol *find_symbol_by_name(struct table *table, const char *name)
|
||||||
|
Loading…
Reference in New Issue
Block a user