Changeset 4183

Show
Ignore:
Timestamp:
06/02/06 17:30:52 (3 years ago)
Author:
morris
Message:

Some optimizations for files/searches

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • WiredClient/trunk/WCFile.h

    r3942 r4183  
    4242        NSString                                *_path; 
    4343        NSDate                                  *_creationDate; 
     44        NSString                                *_creationDateString; 
    4445        NSDate                                  *_modificationDate; 
     46        NSString                                *_modificationDateString; 
    4547        NSString                                *_checksum; 
    4648        NSString                                *_comment; 
  • WiredClient/trunk/WCFile.m

    r3942 r4183  
    3434- (void)_setType:(WCFileType)type; 
    3535- (void)_setPath:(NSString *)path; 
    36 - (void)_setCreationDate:(NSDate *)creationDate
    37 - (void)_setModificationDate:(NSDate *)modificationDate
     36- (void)_setCreationDateString:(NSString *)creationDateString
     37- (void)_setModificationDateString:(NSString *)modificationDateString
    3838- (void)_setChecksum:(NSString *)checksum; 
    3939- (void)_setComment:(NSString *)comment; 
     
    5959 
    6060 
    61 - (void)_setCreationDate:(NSDate *)creationDate
    62         [creationDate retain]; 
    63         [_creationDate release]; 
    64  
    65         _creationDate = creationDate
    66 } 
    67  
    68  
    69  
    70 - (void)_setModificationDate:(NSDate *)modificationDate
    71         [modificationDate retain]; 
    72         [_modificationDate release]; 
    73  
    74         _modificationDate = modificationDate
     61- (void)_setCreationDateString:(NSString *)creationDateString
     62        [creationDateString retain]; 
     63        [_creationDateString release]; 
     64 
     65        _creationDateString = creationDateString
     66} 
     67 
     68 
     69 
     70- (void)_setModificationDateString:(NSString *)modificationDateString
     71        [modificationDateString retain]; 
     72        [_modificationDateString release]; 
     73 
     74        _modificationDateString = modificationDateString
    7575} 
    7676 
     
    259259        [file _setPath:[arguments safeObjectAtIndex:0]]; 
    260260        [file setSize:[[arguments safeObjectAtIndex:2] unsignedLongLongValue]]; 
    261         [file _setCreationDate:[NSDate dateWithISO8601String:[arguments safeObjectAtIndex:3]]]; 
    262         [file _setModificationDate:[NSDate dateWithISO8601String:[arguments safeObjectAtIndex:4]]]; 
     261        [file _setCreationDateString:[arguments safeObjectAtIndex:3]]; 
     262        [file _setModificationDateString:[arguments safeObjectAtIndex:4]]; 
    263263         
    264264        return [file autorelease]; 
     
    274274        [file _setPath:[arguments safeObjectAtIndex:0]]; 
    275275        [file setSize:[[arguments safeObjectAtIndex:2] unsignedLongLongValue]]; 
    276         [file _setCreationDate:[NSDate dateWithISO8601String:[arguments safeObjectAtIndex:3]]]; 
    277         [file _setModificationDate:[NSDate dateWithISO8601String:[arguments safeObjectAtIndex:4]]]; 
     276        [file _setCreationDateString:[arguments safeObjectAtIndex:3]]; 
     277        [file _setModificationDateString:[arguments safeObjectAtIndex:4]]; 
    278278        [file _setChecksum:[arguments safeObjectAtIndex:5]]; 
    279279        [file _setComment:[arguments safeObjectAtIndex:6]]; 
     
    405405 
    406406- (NSDate *)creationDate { 
     407        if(!_creationDate && _creationDateString) 
     408                _creationDate = [[NSDate alloc] initWithISO8601String:_creationDateString]; 
     409         
    407410        return _creationDate; 
    408411} 
     
    411414 
    412415- (NSDate *)modificationDate { 
     416        if(!_modificationDate && _modificationDateString) 
     417                _modificationDate = [[NSDate alloc] initWithISO8601String:_modificationDateString]; 
     418 
    413419        return _modificationDate; 
    414420} 
  • WiredClient/trunk/WCFiles.m

    r4182 r4183  
    399399 
    400400- (void)windowDidLoad { 
    401         WIIconCell              *iconCell; 
    402  
    403         iconCell = [[WIIconCell alloc] init]; 
    404         [_nameTableColumn setDataCell:iconCell]; 
    405         [iconCell release]; 
    406  
    407401        [_filesBrowser setCellClass:[WCFilesBrowserCell class]]; 
    408402        [_filesBrowser setMatrixClass:[WIMatrix class]]; 
     
    473467- (void)windowTemplateShouldSave:(NSMutableDictionary *)windowTemplate { 
    474468        [windowTemplate setObject:[_filesTableView propertiesDictionary] forKey:@"WCFilesTableView"]; 
    475 } 
    476  
    477  
    478  
    479 - (void)connectionDidClose:(NSNotification *)notification { 
    480         [self validate]; 
    481469} 
    482470 
  • WiredClient/trunk/WCFilesController.m

    r4182 r4183  
    3939        self = [super initWithWindowNibName:windowNibName name:name connection:connection]; 
    4040         
    41         _files = [[NSMutableArray alloc] init]; 
     41        _files = [[NSMutableArray alloc] initWithCapacity:5000]; 
    4242         
    4343        [[NSNotificationCenter defaultCenter] 
     
    6464 
    6565- (void)windowDidLoad { 
     66        WIIconCell              *iconCell; 
     67 
     68        iconCell = [[WIIconCell alloc] init]; 
     69        [_nameTableColumn setDataCell:iconCell]; 
     70        [iconCell release]; 
     71 
    6672        [_filesTableView setAllowsUserCustomization:YES]; 
    6773        [_filesTableView setDefaultHighlightedTableColumnIdentifier:@"Name"]; 
     
    7278         
    7379        [super windowDidLoad]; 
     80} 
     81 
     82 
     83 
     84- (void)connectionDidClose:(NSNotification *)notification { 
     85        [self validate]; 
    7486} 
    7587 
  • WiredClient/trunk/WCSearch.h

    r4182 r4183  
    4747        IBOutlet NSButton                                       *_searchButton; 
    4848 
    49         NSMutableArray                                          *_allFiles; 
     49        NSMutableSet                                            *_receivedFiles; 
     50         
     51        WCSearchType                                            _searchType; 
    5052} 
    5153 
  • WiredClient/trunk/WCSearch.m

    r4182 r4183  
    4040@interface WCSearch(Private) 
    4141 
    42 + (NSArray *)_audioFileTypes; 
    43 + (NSArray *)_imageFileTypes; 
    44 + (NSArray *)_movieFileTypes; 
     42+ (NSSet *)_audioFileTypes; 
     43+ (NSSet *)_imageFileTypes; 
     44+ (NSSet *)_movieFileTypes; 
    4545 
    4646- (id)_initSearchWithConnection:(WCServerConnection *)connection; 
     
    5151@implementation WCSearch(Private) 
    5252 
    53 + (NSArray *)_audioFileTypes { 
    54         static NSMutableArray *extensions; 
     53+ (NSSet *)_audioFileTypes { 
     54        static NSMutableSet           *extensions; 
    5555 
    5656        if(!extensions) { 
    57                 extensions = [[NSMutableArray alloc] init]; 
     57                extensions = [[NSMutableSet alloc] init]; 
    5858                [extensions addObjectsFromArray:[[WCSearchTypeAudioExtensions lowercaseString] 
    5959                        componentsSeparatedByString:@" "]]; 
     
    6767 
    6868 
    69 + (NSArray *)_imageFileTypes { 
    70         static NSMutableArray *extensions; 
     69+ (NSSet *)_imageFileTypes { 
     70        static NSMutableSet           *extensions; 
    7171 
    7272        if(!extensions) { 
    73                 extensions = [[NSMutableArray alloc] init]; 
     73                extensions = [[NSMutableSet alloc] init]; 
    7474                [extensions addObjectsFromArray:[[WCSearchTypeImageExtensions lowercaseString] 
    7575                        componentsSeparatedByString:@" "]]; 
     
    8383 
    8484 
    85 + (NSArray *)_movieFileTypes { 
    86         static NSMutableArray *extensions; 
     85+ (NSSet *)_movieFileTypes { 
     86        static NSMutableSet           *extensions; 
    8787 
    8888        if(!extensions) { 
    89                 extensions = [[NSMutableArray alloc] init]; 
     89                extensions = [[NSMutableSet alloc] init]; 
    9090                [extensions addObjectsFromArray:[[WCSearchTypeMovieExtensions lowercaseString] 
    9191                        componentsSeparatedByString:@" "]]; 
     
    106106                                                         connection:connection]; 
    107107 
    108         _allFiles = [[NSMutableArray alloc] init]; 
     108        _receivedFiles = [[NSMutableSet alloc] init]; 
    109109 
    110110        [self window]; 
     
    135135 
    136136- (void)dealloc { 
    137         [_allFiles release]; 
     137        [_receivedFiles release]; 
    138138 
    139139        [super dealloc]; 
     
    145145 
    146146- (void)windowDidLoad { 
    147         WIIconCell              *iconCell; 
    148  
    149         iconCell = [[WIIconCell alloc] init]; 
    150         [_nameTableColumn setDataCell:iconCell]; 
    151         [iconCell release]; 
    152  
    153147        [_filesTableView setDoubleAction:@selector(open:)]; 
    154148         
     
    172166 
    173167 
    174 - (void)connectionDidClose:(NSNotification *)notification { 
    175         [self validate]; 
    176 } 
    177  
    178  
    179  
    180168- (void)connectionWillTerminate:(NSNotification *)notification { 
    181169        [_filesTableView setDataSource:NULL]; 
     
    207195        file = [WCFile fileWithListArguments:[[notification userInfo] objectForKey:WCArgumentsKey]]; 
    208196 
    209         if(![_allFiles containsObject:file]) { 
    210                 switch([[_kindPopUpButton selectedItem] tag]) { 
     197        if(![_receivedFiles containsObject:file]) { 
     198                switch(_searchType) { 
    211199                        case WCSearchTypeAny: 
    212200                                add = YES; 
     
    240228 
    241229                if(add) { 
    242                         [_allFiles addObject:file]; 
    243  
    244                         if([_allFiles count] == 10) { 
    245                                 [_files addObjectsFromArray:_allFiles]; 
    246                                 [_allFiles removeAllObjects]; 
     230                        [_receivedFiles addObject:file]; 
     231 
     232                        if([_receivedFiles count] == 10) { 
     233                                [_files addObjectsFromArray:[_receivedFiles allObjects]]; 
     234                                [_receivedFiles removeAllObjects]; 
    247235 
    248236                                [_filesTableView reloadData]; 
     
    256244- (void)searchCompletedFiles:(NSNotification *)notification { 
    257245        [_progressIndicator stopAnimation:self]; 
    258         [_files addObjectsFromArray:_allFiles]; 
     246        [_files addObjectsFromArray:[_receivedFiles allObjects]]; 
    259247 
    260248        [self updateStatus]; 
    261  
    262249        [self sortFiles]; 
     250         
    263251        [_filesTableView reloadData]; 
    264252        [_filesTableView setNeedsDisplay:YES]; 
     
    299287        if([[_searchTextField stringValue] length] == 0) 
    300288                return; 
    301  
    302         [_allFiles removeAllObjects]; 
     289         
     290        _searchType = [[_kindPopUpButton selectedItem] tag]; 
     291 
     292        [_receivedFiles removeAllObjects]; 
    303293        [_files removeAllObjects]; 
    304294        [_filesTableView reloadData]; 
  • WiredClient/trunk/WCServerConnection.m

    r4148 r4183  
    659659 
    660660- (void)link:(WCLink *)link receivedMessage:(unsigned int)message arguments:(NSArray *)arguments { 
    661         NSString                                *string, *name = NULL; 
     661        NSString                                *name = NULL; 
    662662        NSMutableDictionary             *userInfo; 
    663663        WCError                                 *error; 
    664664         
    665         string = [NSString stringWithFormat:@"%u %@", message, [arguments componentsJoinedByString:@"\t"]]; 
    666665        userInfo = [NSMutableDictionary dictionaryWithObjectsAndKeys: 
    667666                arguments,                                                      WCArgumentsKey, 
     
    836835        } 
    837836 
    838         [self postNotificationName:WCConnectionReceivedMessage object:string]; 
     837 
     838#if defined(DEBUG) || defined(TEST) 
     839        [self postNotificationName:WCConnectionReceivedMessage 
     840                                                object:[NSSWF:@"%u %@", message, [arguments componentsJoinedByString:@"\t"]]]; 
     841#endif 
    839842 
    840843        if(name) 
  • WiredClient/trunk/WCTrackerConnection.m

    r3963 r4183  
    262262 
    263263- (void)link:(WCLink *)link receivedMessage:(unsigned int)message arguments:(NSArray *)arguments { 
    264         NSString                                *string, *name = NULL; 
     264        NSString                                *name = NULL; 
    265265        NSMutableDictionary             *userInfo; 
    266266        WCError                                 *error; 
    267267         
    268         string = [NSString stringWithFormat:@"%u %@", message, [arguments componentsJoinedByString:@"\t"]]; 
    269268        userInfo = [NSMutableDictionary dictionaryWithObjectsAndKeys: 
    270269                arguments,                                                      WCArgumentsKey, 
    271270                [NSNumber numberWithInt:message],       WCMessageKey, 
    272271                NULL]; 
    273  
    274         [self postNotificationName:WCConnectionReceivedMessage object:string]; 
    275272 
    276273        switch(message) { 
     
    309306        } 
    310307 
     308#if defined(DEBUG) || defined(TEST) 
     309        [self postNotificationName:WCConnectionReceivedMessage 
     310                                                object:[NSSWF:@"%u %@", message, [arguments componentsJoinedByString:@"\t"]]]; 
     311#endif 
     312 
    311313        if(name) 
    312314                [self postNotificationName:name object:self userInfo:userInfo];