Revision: 28633
          http://sourceforge.net/p/bibdesk/svn/28633
Author:   hofman
Date:     2024-01-19 18:24:32 +0000 (Fri, 19 Jan 2024)
Log Message:
-----------
use fast enumerations

Modified Paths:
--------------
    trunk/bibdesk_vendorsrc/amaxwell/FileView/FVColorMenuView.m
    trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m
    trunk/bibdesk_vendorsrc/amaxwell/FileView/FVPDFIcon.m
    trunk/bibdesk_vendorsrc/amaxwell/FileView/FVPreviewer.m

Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVColorMenuView.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVColorMenuView.m 2024-01-19 
17:50:18 UTC (rev 28632)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVColorMenuView.m 2024-01-19 
18:24:32 UTC (rev 28633)
@@ -357,9 +357,7 @@
 
 - (void)removeTrackingAreas
 {
-    NSEnumerator *trackEnum = [[NSArray arrayWithArray:[self trackingAreas]] 
objectEnumerator];
-    NSTrackingArea *area;
-    while ((area = [trackEnum nextObject]))
+    for (NSTrackingArea *area in [[[self trackingAreas] copy] autorelease])
         [self removeTrackingArea:area];
 }
 
@@ -416,9 +414,7 @@
 - (NSString *)hoveredLabelName;
 {
     FVColorMenuCell *cell = nil;
-    NSEnumerator *cellEnum = [[self cells] objectEnumerator];
-    
-    while ((cell = [cellEnum nextObject])) {
+    for (cell in [self cells]) {
         if ([cell isHovered])
             break;
     }

Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m      2024-01-19 
17:50:18 UTC (rev 28632)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m      2024-01-19 
18:24:32 UTC (rev 28633)
@@ -1051,9 +1051,7 @@
     
     // mmalc's example unbinds here for a nil superview, but that causes 
problems if you remove the view and add it back in later (and also can cause 
crashes as a side effect, if we're not careful with the datasource)
     if (nil == newSuperview) {
-        NSEnumerator *bindingEnum = [[self exposedBindings] objectEnumerator];
-        NSString *binding;
-        while (binding = [bindingEnum nextObject]) {
+        for (NSString *binding in [self exposedBindings]) {
             if (nil != [self infoForBinding:binding])
                 [self unbind:binding];
         }
@@ -2000,9 +1998,7 @@
     NSMutableSet *toRemove = [NSMutableSet setWithArray:[_zombieIconCache 
allKeys]];
     [toRemove intersectSet:iconURLsToKeep];
     
-    NSEnumerator *keyEnum = [toRemove objectEnumerator];
-    NSURL *aURL;
-    while ((aURL = [keyEnum nextObject])) {
+    for (NSURL *aURL in toRemove) {
         NSParameterAssert([_iconCache objectForKey:aURL] == nil);
         [_iconCache setObject:[_zombieIconCache objectForKey:aURL] 
forKey:aURL];
         [_zombieIconCache removeObjectForKey:aURL];
@@ -2016,8 +2012,7 @@
     [toRemove minusSet:iconURLsToKeep];
     
     // anything remaining in toRemove is not present in the dataSource, so 
transfer from _iconCache to _zombieIconCache
-    keyEnum = [toRemove objectEnumerator];
-    while ((aURL = [keyEnum nextObject])) {
+    for (NSURL *aURL in toRemove) {
         [_zombieIconCache setObject:[_iconCache objectForKey:aURL] 
forKey:aURL];
         [_iconCache removeObjectForKey:aURL];
     }
@@ -2674,15 +2669,12 @@
         }
         
         if ([_progressIndicators count]) {
-            NSEnumerator *urlEnum = [_progressIndicators keyEnumerator];
-            NSURL *url;
-            while ((url = [urlEnum nextObject])) {
-                FVProgressIndicatorCell *progressIndicator = 
[_progressIndicators objectForKey:url];
+            [_progressIndicators enumerateKeysAndObjectsUsingBlock:^(NSURL 
*url, FVProgressIndicatorCell *progressIndicator, BOOL *stop){
                 NSUInteger anIndex = [progressIndicator indexInView];
                 // we only draw a if there's an active download for this 
URL/index pair
                 if (anIndex < [self numberOfIcons] && [[self 
URLAtIndex:anIndex] isEqual:url])
                     [progressIndicator drawWithFrame:[self 
_rectOfProgressIndicatorForIconAtIndex:anIndex]];
-            }
+            }];
         }
     }
 #if DEBUG_GRID 
@@ -3021,13 +3013,11 @@
     
     if (isCopy) {
         NSMutableArray *copiedURLs = [NSMutableArray array];
-        NSEnumerator *urlEnum = [allURLs objectEnumerator];
-        NSURL *aURL;
         NSUInteger i = insertIndex;
         
         downloads = [NSMutableArray array];
         
-        while (aURL = [urlEnum nextObject]) {
+        for (NSURL *aURL in allURLs) {
             if ([aURL isFileURL])
                 aURL = makeCopyOfFileAtURL(aURL);
             else if ([self allowsDownloading])
@@ -3067,9 +3057,7 @@
     }
     
     if ([downloads count]) {
-        NSEnumerator *dlEnum = [downloads objectEnumerator];
-        NSDictionary *dl;
-        while (dl = [dlEnum nextObject]) {
+        for (NSDictionary *dl in downloads) {
             NSUInteger anIndex = [[dl objectForKey:@"index"] 
unsignedIntegerValue];
             NSURL *aURL = [dl objectForKey:@"URL"];
             if (anIndex < [self numberOfIcons] && [aURL isEqual:[self 
URLAtIndex:anIndex]])
@@ -3264,9 +3252,7 @@
 
 - (void)_openURLs:(NSArray *)URLs
 {
-    NSEnumerator *e = [URLs objectEnumerator];
-    NSURL *aURL;
-    while ((aURL = [e nextObject])) {
+    for (NSURL *aURL in URLs) {
         if ([aURL isEqual:[FVIcon missingFileURL]] == NO &&
             ([[self delegate] 
respondsToSelector:@selector(fileView:shouldOpenURL:)] == NO ||
              [[self delegate] fileView:self shouldOpenURL:aURL] == YES))
@@ -3990,9 +3976,7 @@
 
         // if multiple selection, enable unless all the selected URLs are 
missing or non-files
         if (selectionCount > 1) {
-            NSEnumerator *urlEnum = [[self _selectedURLs] objectEnumerator];
-            NSURL *url;
-            while ((url = [urlEnum nextObject])) {
+            for (NSURL *url in [self _selectedURLs]) {
                 // if we find a single file URL that isn't the missing file 
URL, enable the menu
                 if ([url isEqual:[FVIcon missingFileURL]] == NO && [url 
isFileURL])
                     enabled = YES;
@@ -4283,9 +4267,7 @@
 - (void)_cancelDownloads;
 {
     [_downloads makeObjectsPerformSelector:@selector(cancel)];
-    NSEnumerator *downloadEnum = [_downloads objectEnumerator];
-    FVDownload *download;
-    while ((download = [downloadEnum nextObject]))
+    for (FVDownload *download in _downloads)
         [self removeProgressIndicatorForURL:[download downloadURL] 
atIndex:[download indexInView]];
     [_downloads removeAllObjects];
 }
@@ -4370,9 +4352,7 @@
         [self _invalidateProgressTimer];
         [self setNeedsDisplay:YES];
     }
-    NSEnumerator *dlEnum = [_downloads objectEnumerator];
-    FVDownload *download;
-    while ((download = [dlEnum nextObject])) {
+    for (FVDownload *download in _downloads) {
         [self updateProgressIndicator:[download currentProgress] 
forURL:[download downloadURL] atIndex:[download indexInView]];
     }
 }
@@ -4481,11 +4461,10 @@
     if ([aView enclosingScrollView] && [[aView enclosingScrollView] 
tryToPerform:aSelector with:nil])
         return YES;
     
-    NSEnumerator *subviewEnum = [[aView subviews] objectEnumerator];
-    while ((aView = [subviewEnum nextObject]) != nil) {
-        if ([aView isHiddenOrHasHiddenAncestor])
+    for (NSView *aSubview in [aView subviews]) {
+        if ([aSubview isHiddenOrHasHiddenAncestor])
             continue;
-        if ([self _tryToPerform:aSelector inViewAndDescendants:aView])
+        if ([self _tryToPerform:aSelector inViewAndDescendants:aSubview])
             return YES;
     }
     return NO;

Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVPDFIcon.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVPDFIcon.m       2024-01-19 
17:50:18 UTC (rev 28632)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVPDFIcon.m       2024-01-19 
18:24:32 UTC (rev 28633)
@@ -660,9 +660,7 @@
     [_convertedKeysLock lock];
     
     // keys are based on original file, and values are the temp PDF file(s) we 
created, so unlink all those files
-    NSEnumerator *tempURLEnum = [[_convertedKeys allValues] objectEnumerator]; 
 
-    NSURL *aURL;
-    while ((aURL = [tempURLEnum nextObject]) != nil)
+    for (NSURL *aURL in [_convertedKeys allValues])
         unlink([[aURL path] fileSystemRepresentation]);
     
     [_convertedKeys release];

Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVPreviewer.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVPreviewer.m     2024-01-19 
17:50:18 UTC (rev 28632)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVPreviewer.m     2024-01-19 
18:24:32 UTC (rev 28633)
@@ -439,9 +439,7 @@
         return [webviewContextMenuDelegate webView:sender 
contextMenuItemsForElement:element defaultMenuItems:defaultMenuItems];
     } else {
         NSMutableArray *items = [NSMutableArray array];
-        NSEnumerator *itemEnum = [defaultMenuItems objectEnumerator];
-        NSMenuItem *item;
-        while ((item = [itemEnum nextObject])) {
+        for (NSMenuItem *item in defaultMenuItems) {
             NSInteger tag = [item tag];
             if (tag == WebMenuItemTagCopyLinkToClipboard || tag == 
WebMenuItemTagCopyImageToClipboard || tag == WebMenuItemTagCopy || tag == 
WebMenuItemTagGoBack || tag == WebMenuItemTagGoForward || tag == 
WebMenuItemTagStop || tag == WebMenuItemTagReload || tag == WebMenuItemTagOther)
                 [items addObject:item];

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to