|
From: <de...@us...> - 2009-09-27 15:27:00
|
Revision: 1847
http://iterm.svn.sourceforge.net/iterm/?rev=1847&view=rev
Author: delx
Date: 2009-09-27 15:26:50 +0000 (Sun, 27 Sep 2009)
Log Message:
-----------
Speed up [PTYTextView _drawCharacter..] by reusing a single attribute dictionary
Modified Paths:
--------------
trunk/PTYTextView.m
Modified: trunk/PTYTextView.m
===================================================================
--- trunk/PTYTextView.m 2009-09-27 15:05:32 UTC (rev 1846)
+++ trunk/PTYTextView.m 2009-09-27 15:26:50 UTC (rev 1847)
@@ -2452,22 +2452,28 @@
{
if (!code) return;
+ static int oldfg = -1;
+ static NSFont* oldFont = nil;
+ static NSMutableDictionary* attrib = nil;
+ if(attrib == nil) attrib = [[NSMutableDictionary alloc] init];
+
NSFont* theFont = dw?nafont:font;
BOOL renderBold = (fg&BOLD_MASK) && ![self disableBold];
- NSColor* color = [self colorForCode: fg];
+ NSColor* color = [self colorForCode:fg];
- NSDictionary* attrib=[NSDictionary dictionaryWithObjectsAndKeys:
- theFont, NSFontAttributeName, color, NSForegroundColorAttributeName,
- nil];
+ if(oldfg != fg)
+ [attrib setObject:color forKey:NSForegroundColorAttributeName];
+ if(oldFont != theFont)
+ [attrib setObject:theFont forKey: NSFontAttributeName];
- NSString* crap = [NSString stringWithCharacters:&code length:1];
+ NSString* crap = [NSString stringWithCharacters:&code length:1];
[crap drawWithRect:NSMakeRect(X,Y+[theFont ascender], 0, 0) options:0 attributes:attrib];
// redraw the character offset by 1 pixel, this is faster than real bold
- if (renderBold) {
+ if(renderBold) {
[crap drawWithRect:NSMakeRect(X+1,Y+[theFont ascender], 0, 0) options:0 attributes:attrib];
}
-}
+}
- (void) _scrollToLine:(int)line
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|