From: Ben Pfaff Date: Tue, 16 Dec 2003 05:43:20 +0000 (+0000) Subject: * groff-font.c: (add_kern) Fix indentation. X-Git-Tag: v0.4.0~446 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ecd77539d8be24ba673becc0f25bb453f4e2944d;p=pspp-builds.git * groff-font.c: (add_kern) Fix indentation. (add_kern) Use & instead of % to take power-of-2 modulus. (font_get_kern_adjust) Likewise. --- diff --git a/src/ChangeLog b/src/ChangeLog index b3f66814..8b6f4ded 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +Mon Dec 15 21:35:59 2003 Ben Pfaff + + * groff-font.c: (add_kern) Fix indentation. + (add_kern) Use & instead of % to take power-of-2 modulus. + (font_get_kern_adjust) Likewise. + Fri Dec 12 23:54:37 2003 Ben Pfaff * autorecode.c: (recode) Replace stupid use of memcpy() by diff --git a/src/groff-font.c b/src/groff-font.c index d645b278..12572cf4 100644 --- a/src/groff-font.c +++ b/src/groff-font.c @@ -600,23 +600,26 @@ add_kern (struct font_desc *font, int ch1, int ch2, int adjust) for (i = 0; i < font->kern_size; i++) font->kern[i].ch1 = -1; - if (old_kern) { - for (i = 0; i < old_kern_size; i++) - { - if (old_kern[i].ch1 == -1) - continue; - - j = hash_kern (old_kern[i].ch1, old_kern[i].ch2) % font->kern_size; - while (font->kern[j].ch1 != -1) - if (0 == j--) - j = font->kern_size - 1; - font->kern[j] = old_kern[i]; - } - pool_free (font->owner, old_kern); - } + if (old_kern) + { + for (i = 0; i < old_kern_size; i++) + { + if (old_kern[i].ch1 == -1) + continue; + + j = (hash_kern (old_kern[i].ch1, old_kern[i].ch2) + & (font->kern_size - 1)); + while (font->kern[j].ch1 != -1) + if (0 == j--) + j = font->kern_size - 1; + font->kern[j] = old_kern[i]; + } + pool_free (font->owner, old_kern); + } } - for (i = hash_kern (ch1, ch2) % font->kern_size; font->kern[i].ch1 != -1;) + for (i = hash_kern (ch1, ch2) & (font->kern_size - 1); + font->kern[i].ch1 != -1; ) if (0 == i--) i = font->kern_size - 1; font->kern[i].ch1 = ch1; @@ -961,7 +964,8 @@ font_get_kern_adjust (const struct font_desc *font, int ch1, int ch2) if (!font->kern) return 0; - for (i = hash_kern (ch1, ch2) % font->kern_size; font->kern[i].ch1 != -1;) + for (i = hash_kern (ch1, ch2) & (font->kern_size - 1); + font->kern[i].ch1 != -1;) { if (font->kern[i].ch1 == ch1 && font->kern[i].ch2 == ch2) return font->kern[i].adjust;