From 0910eecd89c620eb6015e05e1a9086ced9d4a7c1 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sun, 4 Dec 2016 21:50:55 -0500 Subject: [PATCH] Remove -[Breakpoint hash] and fix -isEqual:. --- Source/Breakpoint.m | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/Source/Breakpoint.m b/Source/Breakpoint.m index 7a4b44c..68b7252 100644 --- a/Source/Breakpoint.m +++ b/Source/Breakpoint.m @@ -96,45 +96,43 @@ NSString* const kBreakpointTypeFunctionEntry = @"call"; return path; } -/** - * Determines if two breakpoints are equal - */ - (BOOL)isEqual:(id)obj { - return ([[obj file] isEqualToString:self.file] && [obj line] == self.line); -} + if (![obj isKindOfClass:[self class]]) { + return NO; + } -/** - * Returns the hash value of a breakpoint - */ -- (NSUInteger)hash -{ - return ([self.file hash] << 8) + self.line; + Breakpoint* other = obj; + if (self.type != other.type) { + return NO; + } + + if (self.type == kBreakpointTypeFile) { + return [self.file isEqualToString:other.file] && self.line == other.line; + } else if (self.type == kBreakpointTypeFunctionEntry) { + return [self.functionName isEqualToString:other.functionName]; + } + + return NO; } -/** - * Returns an NSDictionary of the data so it can be stored in NSUserDefaults - */ - (NSDictionary*)dictionary { - if (_type == kBreakpointTypeFile) { + if (self.type == kBreakpointTypeFile) { return @{ - @"type" : _type, + @"type" : self.type, @"file" : self.file, @"line" : @(self.line) }; - } else if (_type == kBreakpointTypeFunctionEntry) { + } else if (self.type == kBreakpointTypeFunctionEntry) { return @{ - @"type" : _type, + @"type" : self.type, @"function" : self.functionName }; } return nil; } -/** - * Pretty-print - */ - (NSString*)description { return [NSString stringWithFormat:@"Breakpoint %@", [[self dictionary] description]]; -- 2.43.5