From c1b516f2318e6041ab1174de9e4a718de2e74eb8 Mon Sep 17 00:00:00 2001 From: Cedric Bail Date: Mon, 28 Oct 2013 18:54:30 +0900 Subject: [PATCH] terminology: inline the most common case for a small 2% speed up. --- src/bin/termptydbl.c | 12 +----------- src/bin/termptydbl.h | 27 +++++++++++++++++++++++++-- 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/src/bin/termptydbl.c b/src/bin/termptydbl.c index 34151d0c..b4c442d7 100644 --- a/src/bin/termptydbl.c +++ b/src/bin/termptydbl.c @@ -5,21 +5,12 @@ #include "termptydbl.h" Eina_Bool -_termpty_is_dblwidth_get(Termpty *ty, int g) +_termpty_is_dblwidth_slow_get(Termpty *ty, int g) { -#if defined(SUPPORT_DBLWIDTH) // check for east asian full-width (F), half-width (H), wide (W), // narrow (Na) or ambiguous (A) codepoints // ftp://ftp.unicode.org/Public/UNIDATA/EastAsianWidth.txt - // optimize for latin1 non-ambiguous - if (g <= 0xa0) - return EINA_FALSE; - // (F) - if ((g == 0x3000) || - ((g >= 0xff01) && (g <= 0xff60)) || - ((g >= 0xffe0) && (g <= 0xffe6))) - return EINA_TRUE; // (W) if ( // 1XXX @@ -273,6 +264,5 @@ _termpty_is_dblwidth_get(Termpty *ty, int g) } // Na, H -> not checked -#endif return EINA_FALSE; } diff --git a/src/bin/termptydbl.h b/src/bin/termptydbl.h index 04e3e5f3..da9ca5d5 100644 --- a/src/bin/termptydbl.h +++ b/src/bin/termptydbl.h @@ -1,2 +1,25 @@ -Eina_Bool _termpty_is_dblwidth_get(Termpty *ty, int g); - +Eina_Bool _termpty_is_dblwidth_slow_get(Termpty *ty, int g); + +static inline Eina_Bool +_termpty_is_dblwidth_get(Termpty *ty, int g) +{ +#if defined(SUPPORT_DBLWIDTH) + // check for east asian full-width (F), half-width (H), wide (W), + // narrow (Na) or ambiguous (A) codepoints + // ftp://ftp.unicode.org/Public/UNIDATA/EastAsianWidth.txt + + // optimize for latin1 non-ambiguous + if (g <= 0xa0) + return EINA_FALSE; + // (F) + if ((g == 0x3000) || + ((g >= 0xff01) && (g <= 0xff60)) || + ((g >= 0xffe0) && (g <= 0xffe6))) + return EINA_TRUE; + + return _termpty_is_dblwidth_slow_get(ty, g); +#else + return EINA_FALSE; +#endif +} +