Revision: 27583
http://sourceforge.net/p/bibdesk/svn/27583
Author: hofman
Date: 2022-06-08 19:17:07 +0000 (Wed, 08 Jun 2022)
Log Message:
-----------
No need to define method overrides and ivars for table sort descriptors, as we
don't use them anymore.
Modified Paths:
--------------
trunk/bibdesk/BDSKTableSortDescriptor.h
trunk/bibdesk/BDSKTableSortDescriptor.m
Modified: trunk/bibdesk/BDSKTableSortDescriptor.h
===================================================================
--- trunk/bibdesk/BDSKTableSortDescriptor.h 2022-06-08 19:13:53 UTC (rev
27582)
+++ trunk/bibdesk/BDSKTableSortDescriptor.h 2022-06-08 19:17:07 UTC (rev
27583)
@@ -39,14 +39,6 @@
#import <Foundation/Foundation.h>
-@interface BDSKTableSortDescriptor : NSSortDescriptor {
-@protected
- CFArrayRef keys;
- CFIndex keyCount;
- SEL selector;
- BOOL ascending;
-}
-
+@interface BDSKTableSortDescriptor : NSSortDescriptor
+ (BDSKTableSortDescriptor *)tableSortDescriptorForIdentifier:(NSString *)tcID
ascending:(BOOL)ascend;
-
@end
Modified: trunk/bibdesk/BDSKTableSortDescriptor.m
===================================================================
--- trunk/bibdesk/BDSKTableSortDescriptor.m 2022-06-08 19:13:53 UTC (rev
27582)
+++ trunk/bibdesk/BDSKTableSortDescriptor.m 2022-06-08 19:17:07 UTC (rev
27583)
@@ -173,112 +173,4 @@
return [sortDescriptor autorelease];
}
-- (void)cacheKeys;
-{
- // cache the components of the keypath and their count
- keys = CFArrayCreateCopy(CFAllocatorGetDefault(), (CFArrayRef)[[self key]
componentsSeparatedByString:@"."]);
- keyCount = CFArrayGetCount(keys);
-}
-
-- (id)initWithKey:(NSString *)key ascending:(BOOL)flag selector:(SEL)theSel;
-{
- if(self = [super initWithKey:key ascending:flag selector:theSel]){
- [self cacheKeys];
-
- // since NSSortDescriptor ivars are declared @private, we have to use
@defs to access them directly; use our own instead, since this won't be
subclassed
- selector = theSel;
- ascending = flag;
- }
- return self;
-}
-
-- (id)initWithCoder:(NSCoder *)aCoder
-{
- self = [super initWithCoder:aCoder];
- if (self) {
- [self cacheKeys];
- selector = [self selector];
- ascending = [self ascending];
- }
- return self;
-}
-
-- (void)encodeWithCoder:(NSCoder *)aCoder
-{
- [super encodeWithCoder:aCoder];
-}
-
-- (id)copyWithZone:(NSZone *)aZone
-{
- return [[[self class] allocWithZone:aZone] initWithKey:[self key]
ascending:[self ascending] selector:[self selector]];
-}
-
-- (void)dealloc
-{
- BDSKCFDESTROY(keys);
- [super dealloc];
-}
-
-- (id)reversedSortDescriptor
-{
- return [[[[self class] alloc] initWithKey:[self key] ascending:NO ==
ascending selector:selector] autorelease];
-}
-
-static inline void __GetValuesUsingCache(BDSKTableSortDescriptor *sort, id
object1, id object2, id *value1, id *value2)
-{
- CFIndex i;
- *value1 = object1;
- *value2 = object2;
- NSString *key;
-
- // storing the array as an NSString ** buffer really didn't help with
performance, but using CFArray functions does help cut down on the objc overhead
- for(i = 0; i < sort->keyCount; i++){
- key = (NSString *)CFArrayGetValueAtIndex(sort->keys, i);
- *value1 = [*value1 valueForKey:key];
- *value2 = [*value2 valueForKey:key];
- }
-}
-
-- (NSComparisonResult)compareEndObject:(id)value1 toEndObject:(id)value2;
-{
- // check to see if one of the values is nil
- if(value1 == nil){
- if(value2 == nil)
- return NSOrderedSame;
- else
- return (ascending ? NSOrderedDescending : NSOrderedAscending);
- } else if(value2 == nil){
- return (ascending ? NSOrderedAscending : NSOrderedDescending);
- // this check only applies to NSString objects
- } else if([value1 isKindOfClass:[NSString class]] && [value2
isKindOfClass:[NSString class]]){
- if ([value1 isEqualToString:@""]) {
- if ([value2 isEqualToString:@""]) {
- return NSOrderedSame;
- } else {
- return (ascending ? NSOrderedDescending : NSOrderedAscending);
- }
- } else if ([value2 isEqualToString:@""]) {
- return (ascending ? NSOrderedAscending : NSOrderedDescending);
- }
- }
-
- NSComparisonResult result;
-
- // we use the IMP directly since performSelector: returns an id
- typedef NSComparisonResult (*comparatorIMP)(id, SEL, id);
- comparatorIMP comparator = (comparatorIMP)[value1
methodForSelector:selector];
- result = comparator(value1, selector, value2);
-
- return ascending ? result : -result;
-}
-
-- (NSComparisonResult)compareObject:(id)object1 toObject:(id)object2 {
-
- id value1, value2;
- BDSKASSERT_NOT_REACHED("Inefficient code path; use -[NSArray
sortedArrayUsingMergesortWithDescriptors:] instead");
- // get the values in bulk; since the same keypath is used for both
objects, why compute it twice?
- __GetValuesUsingCache(self, object1, object2, &value1, &value2);
- return [self compareEndObject:value1 toEndObject:value2];
-}
-
@end
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