mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-08-25 04:57:03 +00:00
CPLayoutManager: Fix O(N^2) layout bottleneck when loading large text documents
This commit is contained in:
@@ -305,13 +305,17 @@ _oncontextmenuhandler = function () { return false; };
|
||||
|
||||
- (BOOL)_rescuingInvalidFragmentsWasPossibleForGlyphRange:(CPRange)aRange
|
||||
{
|
||||
var l = _lineFragments.length,
|
||||
location = aRange.location,
|
||||
found = NO,
|
||||
targetLine = 0;
|
||||
// 1. EARLY EXIT: If there are no fragments to rescue (e.g. setting new text), do nothing.
|
||||
if (!_lineFragmentsForRescue || _lineFragmentsForRescue.length === 0)
|
||||
return NO;
|
||||
|
||||
// try to find the first linefragment of the desired range
|
||||
for (; targetLine < l; targetLine++)
|
||||
var l = _lineFragments.length,
|
||||
location = aRange.location,
|
||||
found = NO,
|
||||
targetLine = l - 1; // Start from the END of the array
|
||||
|
||||
// 2. REVERSE SEARCH: The fragment we want is almost always at the end.
|
||||
for (; targetLine >= 0; targetLine--)
|
||||
{
|
||||
if (CPLocationInRange(location, _lineFragments[targetLine]._range))
|
||||
{
|
||||
@@ -334,9 +338,6 @@ _oncontextmenuhandler = function () { return false; };
|
||||
newLength = [[_textStorage string].length],
|
||||
removalSkip = 1;
|
||||
|
||||
// if (ABS(newLength - oldLength) > 1)
|
||||
// return NO;
|
||||
|
||||
if (![oldLineFragment isVisuallyIdenticalToFragment:newLineFragment])
|
||||
{
|
||||
isIdentical = NO;
|
||||
|
||||
Reference in New Issue
Block a user