Changeset 839


Ignore:
Timestamp:
Aug 30, 2006, 9:40:36 PM (15 years ago)
Author:
livings124
Message:

Better compare of IP strings.

Location:
trunk/macosx
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/StringAdditions.m

    r777 r839  
    162162    if ([self isEqualToString: string])
    163163        return NSOrderedSame;
     164   
     165    NSArray * selfSections = [self componentsSeparatedByString: @"."],
     166            * newSections = [string componentsSeparatedByString: @"."];
     167   
     168    if ([selfSections count] != [newSections count])
     169        return [[NSNumber numberWithUnsignedInt: [selfSections count]] compare:
     170                            [NSNumber numberWithUnsignedInt: [newSections count]]];
    164171
    165     NSEnumerator * selfSections = [[self componentsSeparatedByString: @"."] objectEnumerator],
    166             * newSections = [[string componentsSeparatedByString: @"."] objectEnumerator];
    167    
     172    NSEnumerator * selfSectionsEnum = [selfSections objectEnumerator], * newSectionsEnum = [newSections objectEnumerator];
     173    NSString * selfString, * newString;
    168174    NSComparisonResult result;
    169     NSString * selfString = [selfSections nextObject], * newString = [newSections nextObject];
    170     while (selfString && newString)
    171     {
     175    while ((selfString = [selfSectionsEnum nextObject]) && (newString = [newSectionsEnum nextObject]))
    172176        if ((result = [selfString compare: newString options: NSNumericSearch]) != NSOrderedSame)
    173177            return result;
    174        
    175         selfString = [selfSections nextObject];
    176         newString = [newSections nextObject];
    177     }
    178178   
    179     if (selfString)
    180         return NSOrderedDescending;
    181     else if (newString)
    182         return NSOrderedAscending;
    183     else
    184         return NSOrderedSame;
     179    return NSOrderedSame;
    185180}
    186181
  • trunk/macosx/TorrentCell.m

    r836 r839  
    107107        [barImage setSize: NSMakeSize(width * 1.5, BAR_HEIGHT)];
    108108
    109     [barImage compositeToPoint: point fromRect: NSMakeRect(0, 0, width, BAR_HEIGHT)
    110                         operation: NSCompositeSourceOver];
     109    [barImage compositeToPoint: point fromRect: NSMakeRect(0, 0, width, BAR_HEIGHT) operation: NSCompositeSourceOver];
    111110}
    112111
Note: See TracChangeset for help on using the changeset viewer.