Skip to content

Commit 57f29c4

Browse files
committed
Add method to the (internal) SBJsonStreamParserState abstract class to avoid an isKindOfClass: check
1 parent 36b738f commit 57f29c4

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

Classes/SBJsonStreamParser.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ - (SBJsonStreamParserStatus)parse:(NSData *)data_ {
172172

173173
for (;;) {
174174

175-
if ([state isKindOfClass:[SBJsonStreamParserStateError class]])
175+
if ([state isError])
176176
return SBJsonStreamParserError;
177177

178178
NSObject *token;

Classes/SBJsonStreamParserState.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,12 @@
3737

3838
@interface SBJsonStreamParserState : NSObject
3939
+ (id)sharedInstance;
40+
4041
- (BOOL)parser:(SBJsonStreamParser*)parser shouldAcceptToken:(sbjson_token_t)token;
4142
- (SBJsonStreamParserStatus)parserShouldReturn:(SBJsonStreamParser*)parser;
4243
- (void)parser:(SBJsonStreamParser*)parser shouldTransitionTo:(sbjson_token_t)tok;
4344
- (BOOL)needKey;
45+
- (BOOL)isError;
4446

4547
- (NSString*)name;
4648

Classes/SBJsonStreamParserState.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ - (NSString*)name {
6262
return @"<aaiie!>";
6363
}
6464

65+
- (BOOL)isError {
66+
return NO;
67+
}
68+
6569
@end
6670

6771
#pragma mark -
@@ -136,6 +140,10 @@ - (SBJsonStreamParserStatus)parserShouldReturn:(SBJsonStreamParser*)parser {
136140
return SBJsonStreamParserError;
137141
}
138142

143+
- (BOOL)isError {
144+
return YES;
145+
}
146+
139147
@end
140148

141149
#pragma mark -

0 commit comments

Comments
 (0)