This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 1/3] Add an inlined fast path for __libdw_form_val_len


Josh Stone <jistone@redhat.com> writes:

> +  /* Small lookup table of forms with fixed lengths.  */
> +  static const uint8_t form_lengths[] =
> +    {
> +      [DW_FORM_data1] = 1, [DW_FORM_ref1] = 1, [DW_FORM_flag] = 1,
> +      [DW_FORM_data2] = 2, [DW_FORM_ref2] = 2,
> +      [DW_FORM_data4] = 4, [DW_FORM_ref4] = 4,
> +      [DW_FORM_data8] = 8, [DW_FORM_ref8] = 8, [DW_FORM_ref_sig8] = 8,
> +    };
> +
> +  /* Note that form_lengths[flag_present] is 0, like every other absent index.
> +   * But since flag_present's length truly is 0, check for it explicitly.  */
> +  if (form == DW_FORM_flag_present)
> +    return 0;

One way to get rid of this if would be to store X | 0x80 in the table
(including 0 | 0x80 for DW_FORM_flag_present), and then return
len ^ 0x80 later.  I don't feel strongly about this though, and
certainly not if it offsets the performance gains again ;)

> +
> +  /* Return immediately for forms with fixed lengths.  */
> +  if (form < sizeof(form_lengths) / sizeof(form_lengths[0]))

Space after sizeof

> +    {
> +      size_t len = form_lengths[form];
> +      if (len != 0)
> +	return len;

Fine otherwise.

Thanks,
PM

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]