From 3b251b8e3d4dc9a694ef76562b388ab07da54785 Mon Sep 17 00:00:00 2001 From: Max Date: Sat, 13 Dec 2014 19:48:41 +0100 Subject: Replace some NSDictionaries with literals MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [NSDictionary dictionary] → @{} * [NSDictionary dictionaryWithObject:forKey:] can safely be replaced. object==nil would have already thrown a NPE in the past. * Also replaced some (hopefully safe) NSArray initializers (ie. their objects should always exist). --- Source/MGTemplateStandardMarkers.m | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) (limited to 'Source/MGTemplateStandardMarkers.m') diff --git a/Source/MGTemplateStandardMarkers.m b/Source/MGTemplateStandardMarkers.m index 543d16a7..5edcb00c 100644 --- a/Source/MGTemplateStandardMarkers.m +++ b/Source/MGTemplateStandardMarkers.m @@ -107,29 +107,20 @@ - (NSArray *)markers { - return [NSArray arrayWithObjects: - FOR_START, FOR_END, - SECTION_START, SECTION_END, - IF_START, ELSE, IF_END, - NOW, - COMMENT_START, COMMENT_END, - LOAD, - CYCLE, - SET, - nil]; + return @[FOR_START, FOR_END, SECTION_START, SECTION_END, IF_START, ELSE, IF_END, NOW, COMMENT_START, COMMENT_END, LOAD, CYCLE, SET]; } - (NSArray *)endMarkersForMarker:(NSString *)marker { if ([marker isEqualToString:FOR_START]) { - return [NSArray arrayWithObjects:FOR_END, nil]; + return @[FOR_END]; } else if ([marker isEqualToString:SECTION_START]) { - return [NSArray arrayWithObjects:SECTION_END, nil]; + return @[SECTION_END]; } else if ([marker isEqualToString:IF_START]) { - return [NSArray arrayWithObjects:IF_END, ELSE, nil]; + return @[IF_END, ELSE]; } else if ([marker isEqualToString:COMMENT_START]) { - return [NSArray arrayWithObjects:COMMENT_END, nil]; + return @[COMMENT_END]; } return nil; } @@ -531,8 +522,7 @@ } else if ([marker isEqualToString:SET]) { if (args && [args count] == 2 && *outputEnabled) { // Set variable arg1 to value arg2. - NSDictionary *newVar = [NSDictionary dictionaryWithObject:[args objectAtIndex:1] - forKey:[args objectAtIndex:0]]; + NSDictionary *newVar = @{[args objectAtIndex:0] : [args objectAtIndex:1]}; if (newVar) { *newVariables = newVar; } -- cgit v1.2.3