Revision: 28949
http://sourceforge.net/p/bibdesk/svn/28949
Author: hofman
Date: 2024-09-27 16:15:58 +0000 (Fri, 27 Sep 2024)
Log Message:
-----------
Look up old category groups for rebuilding in temporary map table to avoid
quadratic comparisons
Modified Paths:
--------------
trunk/bibdesk/BibDocument_Groups.m
Modified: trunk/bibdesk/BibDocument_Groups.m
===================================================================
--- trunk/bibdesk/BibDocument_Groups.m 2024-09-17 14:38:18 UTC (rev 28948)
+++ trunk/bibdesk/BibDocument_Groups.m 2024-09-27 16:15:58 UTC (rev 28949)
@@ -446,13 +446,6 @@
docFlags.ignoreGroupUIChange = NO;
}
-static BDSKCategoryGroup *groupWithName(NSArray *groups, id name) {
- for (BDSKCategoryGroup *aGroup in groups)
- if ([[aGroup name] isEqual:name])
- return aGroup;
- return nil;
-}
-
// this method uses counted sets to compute the number of publications per
group; each group object is just a name
// and a count, and a group knows how to compare itself with other groups for
sorting/equality, but doesn't know
// which pubs are associated with it
@@ -475,12 +468,18 @@
NSHashTable *hashTable = [[NSHashTable alloc]
initWithPointerFunctions:pointerFunctions capacity:0];
CFMutableBagRef bag = CFBagCreateMutable(kCFAllocatorDefault, 0,
&bagCallBacks);
- NSArray *oldGroups = [parent categoryGroups];
- BDSKCategoryGroup *group = [oldGroups firstObject];
+ NSMapTable *oldGroups = nil;
+ BDSKCategoryGroup *group = [[parent categoryGroups] firstObject];
- if ([groupField isEqualToString:[group key]] == NO || [groupField
isPersonField] != [[group name] isKindOfClass:[BibAuthor class]])
- oldGroups = nil;
+ if ([groupField isEqualToString:[group key]] && [groupField isPersonField]
== [[group name] isKindOfClass:[BibAuthor class]]) {
+ oldGroups = [NSMapTable strongToStrongObjectsMapTable];
+ for (BDSKCategoryGroup *aGroup in [parent categoryGroups])
+ [oldGroups setObject:aGroup forKey:[aGroup name]];
+ }
+ NSMapTable *oldGroupTable = [NSMapTable strongToStrongObjectsMapTable];
+
+
NSInteger emptyCount = 0;
NSHashTable *tmpSet = nil;
@@ -501,7 +500,7 @@
// now add the group names that we found from our BibItems, using a
generic folder icon
for (id groupName in hashTable) {
- group = groupWithName(oldGroups, groupName);
+ group = [oldGroups objectForKey:groupName];
// don't reuse groups with invalidated authors
if (isPersonField && [(BibAuthor *)[group name] publication] == nil)
group = nil;
@@ -514,9 +513,8 @@
// add the "empty" group at index 0; this is a group of pubs whose value
is empty for this field, so they
// will not be contained in any of the other groups for the currently
selected group field (hence multiple selection is desirable)
if (emptyCount > 0) {
- if ([oldGroups count] && [[oldGroups objectAtIndex:0] isEmpty])
- group = [oldGroups objectAtIndex:0];
- else
+ group = [oldGroups objectForKey:[BibAuthor emptyAuthor]];
+ if (group == nil)
group = [[BDSKCategoryGroup alloc] initWithName:nil
key:groupField];
[group setCount:emptyCount];
[mutableGroups insertObject:group atIndex:0];
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