Skip to content

Commit 973cb10

Browse files
committed
More performance tweaking.
1 parent 31b0d02 commit 973cb10

File tree

1 file changed

+5
-20
lines changed

1 file changed

+5
-20
lines changed

SCXcodeMinimap/SCXcodeMinimapView.m

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -161,39 +161,24 @@ - (NSDictionary *)layoutManager:(NSLayoutManager *)layoutManager
161161
return nil;
162162
}
163163

164-
// Prevent full range invalidation for performance reasons.
164+
// Delay invalidation for performance reasons.
165165
if(!self.shouldAllowFullSyntaxHighlight) {
166166

167-
// Attempt a full range invalidation after all temporary attributes are set
167+
// Attempt a full range invalidation after
168168
__weak typeof(self) weakSelf = self;
169169
void(^invalidationBlock)() = ^{
170170
weakSelf.shouldAllowFullSyntaxHighlight = YES;
171171
NSRange visibleMinimapRange = [weakSelf.textView visibleCharacterRange];
172172
[weakSelf.textView.layoutManager invalidateDisplayForCharacterRange:visibleMinimapRange];
173173
};
174174

175-
NSRange visibleEditorRange = [self.editorTextView visibleCharacterRange];
176-
if(charIndex > visibleEditorRange.location + visibleEditorRange.length ) {
177-
*effectiveCharRange = NSMakeRange(visibleEditorRange.location + visibleEditorRange.length,
178-
layoutManager.textStorage.length - visibleEditorRange.location - visibleEditorRange.length);
179-
180-
[self performBlock:invalidationBlock afterDelay:kDurationBetweenInvalidations cancelPreviousRequest:YES];
181-
182-
return @{NSForegroundColorAttributeName : [self.theme sourcePlainTextColor]};
183-
}
175+
[self performBlock:invalidationBlock afterDelay:kDurationBetweenInvalidations cancelPreviousRequest:YES];
184176

185-
if(charIndex < visibleEditorRange.location) {
186-
*effectiveCharRange = NSMakeRange(0, visibleEditorRange.location);
187-
188-
[self performBlock:invalidationBlock afterDelay:kDurationBetweenInvalidations cancelPreviousRequest:YES];
189-
190-
return @{NSForegroundColorAttributeName : [self.theme sourcePlainTextColor]};
191-
}
177+
return @{NSForegroundColorAttributeName : [self.theme sourcePlainTextColor]};
192178
}
193179

194180
// Rely on the colorAtCharacterIndex: method to update the effective range
195-
DVTTextStorage *storage = [self.editorTextView textStorage];
196-
NSColor *color = [storage colorAtCharacterIndex:charIndex effectiveRange:effectiveCharRange context:nil];
181+
NSColor *color = [(DVTTextStorage *)[self.editorTextView textStorage] colorAtCharacterIndex:charIndex effectiveRange:effectiveCharRange context:nil];
197182

198183
// Background color for comments and preprocessor directives. Could query for nodeTypeAtCharacterIndex: but it's too slow.
199184
DVTPointerArray *editorColors = [[DVTFontAndColorTheme currentTheme] syntaxColorsByNodeType];

0 commit comments

Comments
 (0)