Skip to content

Commit

Permalink
Made svgNamed use urlForResource:
Browse files Browse the repository at this point in the history
fileURLWithPath: touches the filesystem,
try to minimize main thread io
  • Loading branch information
fjolnir committed Feb 7, 2017
1 parent e86175f commit 49f926c
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions SVGLayer.m
Expand Up @@ -116,8 +116,8 @@ - (void)setSvgName:(NSString *)svgName {

#if !TARGET_INTERFACE_BUILDER
NSBundle * const bundle = [NSBundle mainBundle];
NSString * const path = [bundle pathForResource:svgName ofType:@"svg"];
NSParameterAssert(!svgName || path);
NSURL * const url = [bundle URLForResource:svgName withExtension:@"svg"];
NSParameterAssert(!svgName || url);
#else
NSString *path = nil;
NSPredicate * const pred = [NSPredicate predicateWithFormat:@"lastPathComponent LIKE[c] %@",
Expand All @@ -142,11 +142,10 @@ - (void)setSvgName:(NSString *)svgName {
break;
}
}
NSURL *url = path ? [NSURL fileUrlWithPath:path] : nil;
#endif

if (path) {
self.svgURL = [NSURL fileURLWithPath:path];
}
self.svgURL = url;

#if defined(DEBUG) && !defined(POCKETSVG_DISABLE_FILEWATCH)
int const fdes = open([path fileSystemRepresentation], O_RDONLY);
Expand Down

0 comments on commit 49f926c

Please sign in to comment.