mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 20:01:11 +00:00
(-_generateRunsToCharacter:): Optimize the run structure by merging with an existing run instead of creating a new run under some circumstances.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@16074 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
7069b67123
commit
b48bf809c7
2 changed files with 42 additions and 7 deletions
|
@ -1,3 +1,9 @@
|
|||
2003-02-26 00:47 Alexander Malmberg <alexander@malmberg.org>
|
||||
|
||||
* Source/GSLayoutManager.m (-_generateRunsToCharacter:): Optimize
|
||||
the run structure by merging with an existing run instead of
|
||||
creating a new run under some circumstances.
|
||||
|
||||
2003-02-25 17:38 Alexander Malmberg <alexander@malmberg.org>
|
||||
|
||||
* Source/NSLayoutManager.m
|
||||
|
|
|
@ -391,7 +391,7 @@ static glyph_run_t *run_insert(glyph_run_head_t **context)
|
|||
target. */
|
||||
while (pos <= last)
|
||||
{
|
||||
NSRange maxRange = NSMakeRange(pos, length - pos);
|
||||
NSRange maxRange;
|
||||
NSRange curRange;
|
||||
NSDictionary *attributes;
|
||||
|
||||
|
@ -401,10 +401,45 @@ static glyph_run_t *run_insert(glyph_run_head_t **context)
|
|||
|
||||
int i;
|
||||
|
||||
maxRange = NSMakeRange(pos, length - pos);
|
||||
if (pos > 0)
|
||||
{
|
||||
maxRange.location--;
|
||||
maxRange.length++;
|
||||
}
|
||||
|
||||
attributes = [_textStorage attributesAtIndex: pos
|
||||
longestEffectiveRange: &curRange
|
||||
inRange: maxRange];
|
||||
|
||||
/*
|
||||
Optimize run structure by merging with the previous run under
|
||||
some circumstances. See the comments in
|
||||
-invalidateGlyphsForCharacterRange:changeInLength:actualCharacterRange:
|
||||
for more information.
|
||||
*/
|
||||
if (curRange.location < pos && context[0]->char_length &&
|
||||
context[0]->char_length < 16)
|
||||
{
|
||||
curRange.length -= pos - curRange.location;
|
||||
curRange.location = pos;
|
||||
new = (glyph_run_t *)context[0];
|
||||
if (new->head.complete)
|
||||
{
|
||||
free(new->glyphs);
|
||||
new->glyphs = NULL;
|
||||
new->head.glyph_length = 0;
|
||||
new->head.complete = 0;
|
||||
}
|
||||
new->head.char_length += curRange.length;
|
||||
for (i = 1; i < SKIP_LIST_DEPTH; i++)
|
||||
{
|
||||
run_fix_head(context[i]);
|
||||
}
|
||||
pos = NSMaxRange(curRange);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (curRange.location < pos)
|
||||
{
|
||||
curRange.length -= pos - curRange.location;
|
||||
|
@ -1160,7 +1195,6 @@ places where we switch.
|
|||
free(next->glyphs);
|
||||
next->glyphs = NULL;
|
||||
}
|
||||
/* TODO: this creates really large runs at times */
|
||||
next->head.char_length -= max - cpos;
|
||||
|
||||
hn = &next->head;
|
||||
|
@ -1236,11 +1270,6 @@ places where we switch.
|
|||
This happens a lot with repeated single-character insertions, aka.
|
||||
typing in a text view.
|
||||
*/
|
||||
/*
|
||||
TODO: This is not triggered if a character is added at the very end
|
||||
of the text. Might be a good idea to merge runs in that case, too.
|
||||
Maybe do it in -_generateRunsToCharacter:, instead.
|
||||
*/
|
||||
if (rng.location < ch && context[0]->char_length &&
|
||||
context[0]->char_length < 16)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue