[PATCH 1/7] render: Inline common FindGlyph case

Dave Airlie airlied at gmail.com
Mon May 11 21:27:56 PDT 2015


On 12 May 2015 at 14:23, Keith Packard <keithp at keithp.com> wrote:
> Provide the common path for FindGlyph as an inline function, falling
> back to a function for the slow case.
>
> Signed-off-by: Keith Packard <keithp at keithp.com>
> ---
>  render/glyph.c    |  2 +-
>  render/glyphstr.h | 11 ++++++++++-
>  2 files changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/render/glyph.c b/render/glyph.c
> index f3310db..4a4f11b 100644
> --- a/render/glyph.c
> +++ b/render/glyph.c
> @@ -330,7 +330,7 @@ DeleteGlyph(GlyphSetPtr glyphSet, Glyph id)
>  }
>
>  GlyphPtr
> -FindGlyph(GlyphSetPtr glyphSet, Glyph id)
> +FindGlyphSlow(GlyphSetPtr glyphSet, Glyph id)
>  {
>      GlyphPtr glyph;
>
> diff --git a/render/glyphstr.h b/render/glyphstr.h
> index 2df055d..8772095 100644
> --- a/render/glyphstr.h
> +++ b/render/glyphstr.h
> @@ -115,7 +115,7 @@ extern _X_EXPORT void
>  extern _X_EXPORT Bool
>   DeleteGlyph(GlyphSetPtr glyphSet, Glyph id);
>
> -extern _X_EXPORT GlyphPtr FindGlyph(GlyphSetPtr glyphSet, Glyph id);
> +extern _X_EXPORT GlyphPtr FindGlyphSlow(GlyphSetPtr glyphSet, Glyph id);
>
>  extern _X_EXPORT GlyphPtr AllocateGlyph(xGlyphInfo * gi, int format);
>
> @@ -139,4 +139,13 @@ extern _X_EXPORT PicturePtr
>  extern _X_EXPORT void
>   SetGlyphPicture(GlyphPtr glyph, ScreenPtr pScreen, PicturePtr picture);
>
> +static inline GlyphPtr
> +FindGlyph(GlyphSetPtr glyphSet, Glyph id) {
> +    GlyphHashPtr hash = &glyphSet->hash;
> +    GlyphRefPtr gr = &hash->table[id % hash->hashSet->size];

I'm not sure if I'm right,

but should this check gr == DeletedGlyph?

Dave.

> +    if (gr->signature == id)
> +        return gr->glyph;
> +    return FindGlyphSlow(glyphSet, id);
> +}
> +
>  #endif                          /* _GLYPHSTR_H_ */
> --
> 2.1.4
>
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel


More information about the xorg-devel mailing list