lkml.org 
[lkml]   [2020]   [Mar]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC][PATCH 09/16] objtool: Optimize find_symbol_*() and read_symbols()
On Thu, Mar 12, 2020 at 02:41:16PM +0100, Peter Zijlstra wrote:
> struct symbol *find_symbol_by_offset(struct section *sec, unsigned long offset)
> {
> - struct symbol *sym;
> + struct rb_node *node;
>
> - list_for_each_entry(sym, &sec->symbol_list, list)
> - if (sym->type != STT_SECTION &&
> - sym->offset == offset)
> - return sym;
> + rb_for_each(&sec->symbol_tree, node, &offset, symbol_by_offset) {
> + struct symbol *s = rb_entry(node, struct symbol, node);
> +
> + if (s->offset != offset)
> + continue;
> +
> + if (s->type != STT_SECTION)
> + return s;
> + }

Can be simplified to:

if (s->offset == offset && s->type != STT_SECTION)
return s;

--
Josh

\
 
 \ /
  Last update: 2020-03-15 17:43    [W:0.213 / U:1.128 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site