Changeset 1503

Show
Ignore:
Timestamp:
08/16/04 19:39:49 (4 years ago)
Author:
morris
Message:

cache settings outside the loop

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • WiredClient/trunk/NSMutableAttributedStringAdditions.m

    r1480 r1503  
    1 /* $Id: NSMutableAttributedStringAdditions.m,v 1.20 2004/08/12 17:38:34 morris Exp $ */ 
     1/* $Id: NSMutableAttributedStringAdditions.m,v 1.21 2004/08/16 17:39:49 morris Exp $ */ 
    22 
    33/* 
     
    122122        NSEnumerator                                    *enumerator; 
    123123        NSScanner                                               *scanner; 
    124         NSArray                                                 *lines
     124        NSArray                                                 *lines, *highlightWords
    125125        NSString                                                *line, *word; 
     126        NSColor                                                 *eventTextColor, *timestampEveryLineTextColor, *highlightWordsTextColor; 
    126127        NSRange                                                 range, nickRange; 
    127128        BOOL                                                    foundNick, foundPartialNick, foundAction, foundWord, foundHighlight; 
     
    141142        // --- cache settings here 
    142143        timestampEveryLine = [WCSettings boolForKey:WCTimestampEveryLine]; 
     144        eventTextColor = [WCSettings archivedObjectForKey:WCEventTextColor]; 
     145        timestampEveryLineTextColor = [WCSettings archivedObjectForKey:WCTimestampEveryLineTextColor]; 
     146        highlightWords = [WCSettings objectForKey:WCHighlightWordsWords]; 
     147        highlightWordsTextColor = [WCSettings archivedObjectForKey:WCHighlightWordsTextColor]; 
    143148         
    144149        // --- loop over every line 
     
    151156                [scanner setCharactersToBeSkipped:NULL]; 
    152157                 
    153                 while(![scanner isAtEnd]) { 
     158                while(![scanner isAtEnd] && !foundHighlight) { 
    154159                        [scanner skipUpToCharactersFromSet:nonwhitespace]; 
    155160                        range.location = [scanner scanLocation]; 
     
    163168                                 
    164169                                [self addAttribute:NSForegroundColorAttributeName 
    165                                                          value:[WCSettings archivedObjectForKey:WCEventTextColor] 
     170                                                         value:eventTextColor 
    166171                                                         range:range]; 
    167172 
     
    176181                                         
    177182                                        [self addAttribute:NSForegroundColorAttributeName 
    178                                                                  value:[WCSettings archivedObjectForKey:WCTimestampEveryLineTextColor] 
     183                                                                 value:timestampEveryLineTextColor 
    179184                                                                 range:range]; 
    180185                                        continue; 
     
    224229                         
    225230                        // --- every word in actual chat 
    226                         if(foundNick && !foundHighlight && [[WCSettings objectForKey:WCHighlightWordsWords] containsSubstring:word]) { 
     231                        if(foundNick && !foundHighlight && [highlightWords containsSubstring:word]) { 
    227232                                nickRange.location += offset; 
    228233                 
    229234                                [self addAttribute:NSForegroundColorAttributeName 
    230                                                          value:[WCSettings archivedObjectForKey:WCHighlightWordsTextColor] 
     235                                                         value:highlightWordsTextColor 
    231236                                                         range:nickRange]; 
    232237