From ce4083ecccf0bab6f5e20338f61aeac711fa3706 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Wed, 10 Jun 2020 14:21:50 +0200 Subject: [PATCH] dwrite: Use BitScanReverse instead of dwrite_log2i. Signed-off-by: Jacek Caban Signed-off-by: Nikolay Sivov Signed-off-by: Alexandre Julliard --- dlls/dwrite/opentype.c | 32 +------------------------------- 1 file changed, 1 insertion(+), 31 deletions(-) diff --git a/dlls/dwrite/opentype.c b/dlls/dwrite/opentype.c index e30cc4abe1b..cb79a68d59e 100644 --- a/dlls/dwrite/opentype.c +++ b/dlls/dwrite/opentype.c @@ -3518,36 +3518,6 @@ static inline unsigned int dwrite_popcount(unsigned int x) #endif } -static inline unsigned int dwrite_log2i(unsigned int x) -{ -#if defined(__GNUC__) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3))) - return __builtin_clz(x) ^ 0x1f; -#else - static const unsigned int l[] = - { - ~0u, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - }; - unsigned int i; - - return (i = x >> 16) ? (x = i >> 8) ? l[x] + 24 : l[i] + 16 : (i = x >> 8) ? l[i] + 8 : l[x]; -#endif -} - static float opentype_scale_gpos_be_value(WORD value, float emsize, UINT16 upem) { return (short)GET_BE_WORD(value) * emsize / upem; @@ -4650,7 +4620,7 @@ static void opentype_layout_collect_lookups(struct scriptshaping_context *contex if ((feature->flags & FEATURE_GLOBAL) && feature->max_value == 1) bits_needed = 0; else - bits_needed = min(8, dwrite_log2i(feature->max_value)); + BitScanReverse(&bits_needed, min(feature->max_value, 256)); if (!feature->max_value || next_bit + bits_needed > 8 * sizeof (feature->mask)) continue;