From df25135a4d2007510b03487b517dad13b23f1a98 Mon Sep 17 00:00:00 2001 From: Chris Young Date: Sat, 28 Feb 2015 12:41:50 +0000 Subject: micro-optimisation --- amiga/font.c | 14 +++++++------- amiga/font_bitmap.c | 7 ++++--- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/amiga/font.c b/amiga/font.c index f930f77d6..1f3269e5c 100644 --- a/amiga/font.c +++ b/amiga/font.c @@ -549,7 +549,7 @@ static struct OutlineFont *ami_open_outline_font(const plot_font_style_t *fstyle return NULL; } -static int32 ami_font_plot_glyph(struct OutlineFont *ofont, struct RastPort *rp, +static inline int32 ami_font_plot_glyph(struct OutlineFont *ofont, struct RastPort *rp, uint16 *char1, uint16 *char2, uint32 x, uint32 y, uint32 emwidth, bool aa) { struct GlyphMap *glyph; @@ -562,12 +562,12 @@ static int32 ami_font_plot_glyph(struct OutlineFont *ofont, struct RastPort *rp, struct BulletBase *BulletBase = ofont->BulletBase; #endif - if ((*char1 >= 0xD800) && (*char1 <= 0xDBFF)) { + if (__builtin_expect(((*char1 >= 0xD800) && (*char1 <= 0xDBFF)), 0)) { /* We don't support UTF-16 surrogates yet, so just return. */ return 0; } - if ((*char2 >= 0xD800) && (*char2 <= 0xDBFF)) { + if (__builtin_expect(((*char2 >= 0xD800) && (*char2 <= 0xDBFF)), 0)) { /* Don't attempt to kern a UTF-16 surrogate */ *char2 = 0; } @@ -640,7 +640,7 @@ static int32 ami_font_plot_glyph(struct OutlineFont *ofont, struct RastPort *rp, return char_advance; } -static int32 ami_font_width_glyph(struct OutlineFont *ofont, +static inline int32 ami_font_width_glyph(struct OutlineFont *ofont, const uint16 *char1, const uint16 *char2, uint32 emwidth) { int32 char_advance = 0; @@ -653,12 +653,12 @@ static int32 ami_font_width_glyph(struct OutlineFont *ofont, struct BulletBase *BulletBase = ofont->BulletBase; #endif - if ((*char1 >= 0xD800) && (*char1 <= 0xDBFF)) { + if (__builtin_expect(((*char1 >= 0xD800) && (*char1 <= 0xDBFF)), 0)) { /* We don't support UTF-16 surrogates yet, so just return. */ return 0; } - - if ((*char2 >= 0xD800) && (*char2 <= 0xDBFF)) { + + if (__builtin_expect(((*char2 >= 0xD800) && (*char2 <= 0xDBFF)), 0)) { /* Don't attempt to kern a UTF-16 surrogate */ skip_c2 = true; } diff --git a/amiga/font_bitmap.c b/amiga/font_bitmap.c index 0b5b7ce85..8f142ae6b 100644 --- a/amiga/font_bitmap.c +++ b/amiga/font_bitmap.c @@ -202,11 +202,12 @@ bool amiga_bm_nsfont_split(const plot_font_style_t *fstyle, co--; } - *char_offset = co; - if(string && co) { + if(co > 0) { *actual_x = TextLength(glob->rp, string, co); + *char_offset = co; } else { - *actual_x = 0; + *actual_x = x; + *char_offset = length; } ami_font_bm_close(bmfont); -- cgit v1.2.3