Skip to content

Commit

Permalink
Try to resolve merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
gnachman committed Nov 20, 2013
2 parents 3c40777 + ae70622 commit 1e99612
Show file tree
Hide file tree
Showing 33 changed files with 2,279 additions and 1,572 deletions.
4 changes: 3 additions & 1 deletion CharacterRun.h
Expand Up @@ -11,6 +11,8 @@
#import <ApplicationServices/ApplicationServices.h>
#import "ScreenChar.h"

@class CRunSet;

// Backing storage for CRuns.
@interface CRunStorage : NSObject {
// There are |capacity_| elements in each of these, of which |used_|
Expand All @@ -24,7 +26,7 @@
int used_; // Number of elements in use.

// Like an autorelease pool, but avoids multiple retain/release's per object.
NSMutableSet *colors_;
CRunSet *colors_;
}

// Create a new CRunStorage with space preallocated for |capacity| characters.
Expand Down
48 changes: 47 additions & 1 deletion CharacterRun.m
Expand Up @@ -9,6 +9,52 @@
#import "CharacterRun.h"
#import "ScreenChar.h"

// A mutable set that only uses pointer equality.
@interface CRunSet : NSObject {
NSMutableDictionary *dict_;
}

- (void)addObject:(NSObject *)object;
- (BOOL)containsObject:(NSObject *)object;
- (NSArray *)values;

@end

@implementation CRunSet
- (id)init {
self = [super init];
if (self) {
dict_ = [[NSMutableDictionary alloc] init];
}
return self;
}

- (void)dealloc {
[dict_ release];
[super dealloc];
}

- (NSNumber *)keyForObject:(NSObject *)object {
return [NSNumber numberWithLongLong:(long long)object];
}

- (void)addObject:(NSObject *)object {
NSNumber *key = [self keyForObject:object];
if (![dict_ objectForKey:key]) {
[dict_ setObject:object forKey:key];
}
}

- (BOOL)containsObject:(NSObject *)object {
return [dict_ objectForKey:[self keyForObject:object]] != nil;
}

- (NSArray *)values {
return [dict_ allValues];
}

@end

@implementation CRunStorage : NSObject

+ (CRunStorage *)cRunStorageWithCapacity:(int)capacity {
Expand All @@ -23,7 +69,7 @@ - (id)initWithCapacity:(int)capacity {
glyphs_ = malloc(sizeof(CGGlyph) * capacity);
advances_ = malloc(sizeof(NSSize) * capacity);
capacity_ = capacity;
colors_ = [[NSMutableSet alloc] init];
colors_ = [[CRunSet alloc] init];
used_ = 0;
}
return self;
Expand Down

0 comments on commit 1e99612

Please sign in to comment.