From a3759ab0ef10a9970fafc6d4c6d282e2d6de8e9c Mon Sep 17 00:00:00 2001 From: Richard Wilson Date: Wed, 4 Jan 2006 17:26:43 +0000 Subject: [PATCH] [project @ 2006-01-04 17:26:43 by rjw] Optimise searching for sprites. svn path=/import/netsurf/; revision=1979 --- riscos/wimp.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/riscos/wimp.c b/riscos/wimp.c index 2539321ba..fa667d1d6 100644 --- a/riscos/wimp.c +++ b/riscos/wimp.c @@ -35,6 +35,8 @@ static bool ro_gui_wimp_read_eig_factors(os_mode mode, int *xeig, int *yeig); static wimpextend_furniture_sizes furniture_sizes; static wimp_w furniture_window = NULL; +unsigned char last_sprite_found[16]; + /** * Gets the horzontal scrollbar height * @@ -691,6 +693,11 @@ bool ro_gui_wimp_sprite_exists(const char *sprite) { os_error *error; + /* make repeated calls fast */ + if (!strncmp(sprite, last_sprite_found, 16)) + return true; + + /* fallback if not known to exist */ error = xwimpspriteop_select_sprite(sprite, 0); if (error) { if (error->errnum != error_SPRITE_OP_DOESNT_EXIST) { @@ -700,6 +707,7 @@ bool ro_gui_wimp_sprite_exists(const char *sprite) } return false; } + snprintf(last_sprite_found, 16, sprite); return true; }