Revision: 27764
          http://sourceforge.net/p/bibdesk/svn/27764
Author:   hofman
Date:     2022-07-24 19:24:25 +0000 (Sun, 24 Jul 2022)
Log Message:
-----------
Only reload icon URLs when using dataSource. More efficient addition of 
accessibilty children.

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

Modified: trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m
===================================================================
--- trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m      2022-07-24 
19:15:06 UTC (rev 27763)
+++ trunk/bibdesk_vendorsrc/amaxwell/FileView/FVFileView.m      2022-07-24 
19:24:25 UTC (rev 27764)
@@ -1814,9 +1814,9 @@
 
 - (void)_reloadIcons;
 {
-    BOOL isBound = nil != _contentBinding;
+    BOOL hasDataSource = nil == _contentBinding && nil != _dataSource;
     
-    if (NO == isBound) {
+    if (hasDataSource) {
         [self willChangeValueForKey:@"iconURLs"];
         if (nil == _orderedURLs)
             _orderedURLs = [[NSMutableArray alloc] init];
@@ -1826,7 +1826,6 @@
     
     [_orderedIcons removeAllObjects];
     [_orderedSubtitles removeAllObjects];
-    [_accessibilityIcons removeAllObjects];
     
     CFDictionaryRemoveAllValues(_infoTable);
     
@@ -1855,16 +1854,16 @@
     id (*subtitleAtIndex)(id, SEL, id, NSUInteger);
     subtitleAtIndex = (id (*)(id, SEL, id, NSUInteger))[(id)_dataSource 
methodForSelector:subtitleSel];
     
-    NSUInteger i, iMax = isBound ? [_orderedURLs count] : [_dataSource 
numberOfURLsInFileView:self];
+    NSUInteger i, iMax = hasDataSource ? [_dataSource 
numberOfURLsInFileView:self] : [_orderedURLs count];
     
     for (i = 0; i < iMax; i++) {
-        NSURL *aURL = isBound ? objectAtIndex(_orderedURLs, objectSel, i) : 
URLAtIndex(_dataSource, URLSel, self, i);
+        NSURL *aURL = hasDataSource ? URLAtIndex(_dataSource, URLSel, self, i) 
: objectAtIndex(_orderedURLs, objectSel, i);
         if (__builtin_expect(nil == aURL || [NSNull null] == (id)aURL, 0))
             aURL = [FVIcon missingFileURL];
         NSParameterAssert(nil != aURL && [NSNull null] != (id)aURL);
         FVIcon *icon = cachedIcon(self, cachedIconSel, aURL);
         NSParameterAssert(nil != icon);
-        if (NO == isBound)
+        if (hasDataSource)
             insertObjectAtIndex(_orderedURLs, insertSel, aURL, i);
         insertObjectAtIndex(_orderedIcons, insertSel, icon, i);
         if (_orderedSubtitles)
@@ -1871,22 +1870,26 @@
             insertObjectAtIndex(_orderedSubtitles, insertSel, 
subtitleAtIndex(_dataSource, subtitleSel, self, i), i);
     }
     
+    if (hasDataSource)
+        [self didChangeValueForKey:@"iconURLs"];
+    
     NSUInteger accessibilityCount = [_accessibilityIcons count];
     
     if (accessibilityCount < iMax) {
         if (nil == _accessibilityIcons)
             _accessibilityIcons = [[NSMutableArray alloc] init];
+        // -[NSCFArray addObject:] (do /not/ use +[NSMutableArray 
instanceMethodForSelector:]!)
+        SEL addSel = @selector(addObject:);
+        void (*addObject)(id, SEL, id);
+        addObject = (void (*)(id, SEL, id))[_accessibilityIcons 
methodForSelector:addSel];
         for (i = accessibilityCount; i < iMax; i++) {
             FVAccessibilityIconElement *element = [[FVAccessibilityIconElement 
alloc] initWithIndex:i parent:self];
-            [_accessibilityIcons addObject:element];
+            addObject(_accessibilityIcons, addSel, element);
             [element release];
         }
     } else if (accessibilityCount > iMax) {
         [_accessibilityIcons removeObjectsInRange:NSMakeRange(iMax, 
accessibilityCount - iMax)];
     }
-    
-    if (NO == isBound)
-        [self didChangeValueForKey:@"iconURLs"];
 }
 
 - (void)reloadIcons;

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