[PATCH 1/7] render: Inline common FindGlyph case
Keith Packard
keithp at keithp.com
Mon May 11 21:23:52 PDT 2015
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];
+ if (gr->signature == id)
+ return gr->glyph;
+ return FindGlyphSlow(glyphSet, id);
+}
+
#endif /* _GLYPHSTR_H_ */
--
2.1.4
More information about the xorg-devel
mailing list