From 4c6abe1c7c8abcf203572bbf86b21d97ea4e756f Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Mon, 30 Jul 2007 21:43:20 -0700 Subject: [PATCH] Split HashGlyph functionality out into HashGlyphInfoAndBits This is in preparation for a future change that will take advantage of being able to compute a hash for a separate xGlyphInfo and chunk of bits without a combined Glyph object. --- render/glyph.c | 23 ++++++++++++++++++++--- render/glyphstr.h | 3 +++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/render/glyph.c b/render/glyph.c index 583a52ba3..53c00b326 100644 --- a/render/glyph.c +++ b/render/glyph.c @@ -461,18 +461,35 @@ FindGlyphRef (GlyphHashPtr hash, CARD32 signature, Bool match, GlyphPtr compare) } CARD32 -HashGlyph (GlyphPtr glyph) +HashGlyphInfoAndBits (xGlyphInfo *gi, CARD8 *data, unsigned int size) { - CARD32 *bits = (CARD32 *) &(glyph->info); + CARD32 *bits; CARD32 hash; - int n = glyph->size / sizeof (CARD32); + int n; hash = 0; + + bits = (CARD32 *) gi; + n = sizeof (xGlyphInfo) / sizeof (CARD32); while (n--) hash ^= *bits++; + + bits = (CARD32 *) data; + n = size / sizeof (CARD32); + while (n--) + hash ^= *bits++; + return hash; } +CARD32 +HashGlyph (GlyphPtr glyph) +{ + return HashGlyphInfoAndBits (&glyph->info, + (CARD8 *) (&glyph->info + 1), + glyph->size - sizeof (xGlyphInfo)); +} + #ifdef CHECK_DUPLICATES void DuplicateRef (GlyphPtr glyph, char *where) diff --git a/render/glyphstr.h b/render/glyphstr.h index 22150deee..b941dabaf 100644 --- a/render/glyphstr.h +++ b/render/glyphstr.h @@ -129,6 +129,9 @@ FindGlyphHashSet (CARD32 filled); GlyphRefPtr FindGlyphRef (GlyphHashPtr hash, CARD32 signature, Bool match, GlyphPtr compare); +CARD32 +HashGlyphInfoAndBits (xGlyphInfo *gi, CARD8 *data, unsigned int size); + CARD32 HashGlyph (GlyphPtr glyph);