Revision: 22609
http://sourceforge.net/p/bibdesk/svn/22609
Author: hofman
Date: 2018-09-15 12:09:04 +0000 (Sat, 15 Sep 2018)
Log Message:
-----------
No need for separate array of names to find old group
Modified Paths:
--------------
trunk/bibdesk/BibDocument_Groups.m
Modified: trunk/bibdesk/BibDocument_Groups.m
===================================================================
--- trunk/bibdesk/BibDocument_Groups.m 2018-09-15 11:38:04 UTC (rev 22608)
+++ trunk/bibdesk/BibDocument_Groups.m 2018-09-15 12:09:04 UTC (rev 22609)
@@ -427,6 +427,13 @@
CFBagAddValue(ctxt->bag, value);
}
+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
@@ -459,13 +466,10 @@
setAndBag.bag = CFBagCreateMutable(kCFAllocatorDefault, 0,
&kBDSKCaseInsensitiveStringBagCallBacks);
}
- NSArray *oldGroups = [parent categoryGroups];
- NSArray *oldGroupNames = [NSArray array];
+ NSArray *oldGroups = nil;
if ([groupField isEqualToString:[[oldGroups lastObject] key]] &&
[groupField isPersonField] == [[(BDSKGroup *)[oldGroups lastObject] name]
isKindOfClass:[BibAuthor class]])
- oldGroupNames = [oldGroups valueForKey:@"name"];
- else
- oldGroups = nil;
+ oldGroups = [parent categoryGroups];
NSInteger emptyCount = 0;
@@ -483,13 +487,13 @@
// now add the group names that we found from our BibItems, using a
generic folder icon
for (id groupName in (NSSet *)(setAndBag.set)) {
- NSUInteger idx = [oldGroupNames indexOfObject:groupName];
- if (idx != NSNotFound) {
- group = [[oldGroups objectAtIndex:idx] retain];
- if (isPersonField && [(BibAuthor *)[group name] publication]
== nil)
- BDSKDESTROY(group);
- }
- if (group == nil)
+ group = groupWithName(oldGroups, groupName);
+ // don't reuse groups with invalidated authors
+ if (isPersonField && [(BibAuthor *)[group name] publication] ==
nil)
+ group = nil;
+ if (group)
+ [group retain];
+ else
group = [[BDSKCategoryGroup alloc] initWithName:groupName
key:groupField];
[group setCount:CFBagGetCountOfValue(setAndBag.bag, groupName)];
[mutableGroups addObject:group];
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