r37896 - in trunk/gui/skin: font.c font.h
Author: ib Date: Wed Sep 7 14:23:07 2016 New Revision: 37896 Log: Dramatically speed up fntRead(). Don't scan all existing bit8_chr slots for a free one when adding a new bit8_chr, but use a counter in order to directly access the next free slot. This speeds up scanning the font description file by approx. 97%. Modified: trunk/gui/skin/font.c trunk/gui/skin/font.h Modified: trunk/gui/skin/font.c ============================================================================== --- trunk/gui/skin/font.c Wed Sep 7 14:11:29 2016 (r37895) +++ trunk/gui/skin/font.c Wed Sep 7 14:23:07 2016 (r37896) @@ -232,23 +232,15 @@ int fntRead(char *path, char *fname) cutStr(item, item, '"', 1); if (item[0] & 0x80) { - for (i = 0;; i++) { - if (i == Fonts[id]->extra_chrs) { + if (Fonts[id]->bit8_count % EXTRA_CHRS == 0) { if (!fntAllocChr(Fonts[id], EXTRA_CHRS) || !fntAllocBit8Chr(Fonts[id], EXTRA_CHRS)) - break; - } - - if (!(Fonts[id]->bit8_chr + i * UTF8LENGTH)[0]) { - strncpy(Fonts[id]->bit8_chr + i * UTF8LENGTH, item, UTF8LENGTH); - break; + continue; } - } - if (i == Fonts[id]->extra_chrs) - continue; + strncpy(Fonts[id]->bit8_chr + Fonts[id]->bit8_count * UTF8LENGTH, item, UTF8LENGTH); - i += ASCII_CHRS; + i = Fonts[id]->bit8_count++ + ASCII_CHRS; } else i = item[0]; @@ -334,7 +326,7 @@ static int fntGetCharIndex(int id, unsig *str += direction; } - for (i = 0; (i < Fonts[id]->extra_chrs) && (Fonts[id]->bit8_chr + i * UTF8LENGTH)[0]; i++) { + for (i = 0; i < Fonts[id]->bit8_count; i++) { if (strncmp(Fonts[id]->bit8_chr + i * UTF8LENGTH, uchar, UTF8LENGTH) == 0) return i + ASCII_CHRS; Modified: trunk/gui/skin/font.h ============================================================================== --- trunk/gui/skin/font.h Wed Sep 7 14:11:29 2016 (r37895) +++ trunk/gui/skin/font.h Wed Sep 7 14:23:07 2016 (r37896) @@ -34,6 +34,7 @@ typedef struct { fntChar *Chr; int extra_chrs; unsigned char *bit8_chr; + int bit8_count; guiImage Bitmap; char name[MAX_FONT_NAME]; } bmpFont;
participants (1)
-
ib