On Tue, Apr 28, 2026 at 5:23 PM Josh Poimboeuf <[email protected]> wrote:
[...]
> > Also a few nitpicks below.
> >
> > > Signed-off-by: Josh Poimboeuf <[email protected]>
> > > ---
> > [...]
> > > +static struct symbol *find_twin(struct elfs *e, struct symbol *sym1)
> > > +{
> > > +       struct symbol *name_last = NULL, *scope_last = NULL,
> > > +                     *file_last = NULL, *csum_last = NULL;
> > > +       unsigned int name_orig = 0, name_patched = 0;
> > > +       unsigned int scope_orig = 0, scope_patched = 0;
> > > +       unsigned int file_orig = 0, file_patched = 0;
> > > +       unsigned int csum_orig = 0, csum_patched = 0;
> > > +       struct symbol *sym2, *match = NULL;
> > > +
> > > +       /* Count orig candidates */
> > > +       for_each_sym_by_demangled_name(e->orig, sym1->demangled_name, 
> > > sym2) {
> > > +               if (sym2->twin || sym1->type != sym2->type || 
> > > dont_correlate(sym2) ||
> > > +                   (!maybe_same_file(sym1, sym2)))
> > >                         continue;
> > >
> > > -               count++;
> > > -               result = sym2;
> > > +               /* Level 1: name match (widest filter)  */
> > > +               name_orig++;
> > > +
> > > +               /* Level 2: scope (scope changes allowed) */
> > > +               if (is_tu_local_sym(sym1) != is_tu_local_sym(sym2))
> >
> > is_tu_local_sym(sym1) is called many times, shall we add a variable
> > for it?
>
> Unless it's actually a performance issue I'd prefer not to add yet
> another bit to struct symbol.

We don't need to add it to struct symbol, a local variable for sym1
will be good. No need for sym2.

IOW, we have something like

bool sym1_is_local = is_tu_local_sym(sym1);
...
if (sym1_is_local != is_tu_local_sym(sym2))
...

Thanks,
Song

Reply via email to