Add some framework support for caching the last accessed run.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@15980 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Alexander Malmberg 2003-02-17 01:19:34 +00:00
parent d6239b2d59
commit 1ba6d8c940
3 changed files with 42 additions and 1 deletions

View file

@ -191,6 +191,21 @@ glyph_run_t *GSLayoutManager_run_for_glyph_index(unsigned int glyphIndex,
if (glyphs->glyph_length <= glyphIndex)
return NULL;
#if 0
if (cached_run)
{
if (glyphIndex >= cached_pos &&
glyphIndex < cached_pos + cached_run->head.glyph_length)
{
if (glyph_pos)
*glyph_pos = cached_pos;
if (char_pos)
*char_pos = cached_cpos;
return cached_run;
}
}
#endif
pos = cpos = 0;
level = SKIP_LIST_DEPTH;
h = glyphs;
@ -223,6 +238,13 @@ glyph_run_t *GSLayoutManager_run_for_glyph_index(unsigned int glyphIndex,
*glyph_pos = pos;
if (char_pos)
*char_pos = cpos;
#if 0
cached_run = (glyph_run_t *)h;
cached_pos = pos;
cached_cpos = cpos;
#endif
return (glyph_run_t *)h;
}
}
@ -900,6 +922,11 @@ it should still be safe. might lose opportunities to merge runs, though.
NSRange rng;
/*
We always clear out the cached run information to be safe.
*/
cached_run = NULL;
/* [self _glyphDumpRuns];
printf("range=(%i+%i) lengthChange=%i\n", range.location, range.length, lengthChange);*/
range.length -= lengthChange;