Subject: bug#12541: Prefer plain 'static' to 'static inline'.

From: Eli Zaretskii <[email-masked]>
Date: Mon, 01 Oct 2012 19:14:00 +0200

> Date: Sun, 30 Sep 2012 11:48:15 -0700
> From: Paul Eggert <[email-masked]>
> CC: [email-masked]
> 
> >> With the proposed change, the set of functions that are not always
> >> inlined expands to bidi_cache_iterator_state, bidi_char_at_pos, and
> >> bidi_fetch_char, and (if we also include functions that are partially
> >> inlined) bidi_cache_search and bidi_get_type.
> > 
> > Were they also not inlined before the change?
> 
> Most of these functions were inlined before the change.  However, as
> described above, bidi_char_at_pos was only partially inlined before
> the change.

It surprises me that bidi_char_at_pos is only partially inlined, or
not at all, since its body is just this:

  static inline int
  bidi_char_at_pos (ptrdiff_t bytepos, const unsigned char *s, bool unibyte)
  {
    if (s)
      {
	s += bytepos;
	if (unibyte)
	  return *s;
      }
    else
      s = BYTE_POS_ADDR (bytepos);
    return STRING_CHAR (s);
  }

Perhaps that's because STRING_CHAR could call a function?

Likewise with bidi_get_type.  This one was supposed to be as fast as
the C ctype macros, or close.  Handa-san told me that the uniprop
tables he implemented for this should really be fast.  Maybe again the
problem is that CHAR_TABLE_REF can call a function?

Anyway, it's disturbing that the functions you mention will no longer
be inlined, because they are at the lowest level of walking the buffer
and deciding what to do with the next character.  In particular,
bidi_get_type and bidi_fetch_char are invoked for every character we
display, even if there's no R2L characters anywhere in sight.  (By
contrast, bidi_cache_iterator_state and bidi_cache_search will only be
invoked if we bump into an R2L character.)

Nevertheless, I'm okay with removing the 'inline' qualifier from
bidi.c.  If the performance hit is significant, I'm sure we will hear
from users shortly.  Otherwise, I'll try to measure the performance
with and without 'inline' when I have time, and we can take it from
there.