Permalink
Browse files

Merge pull request #205 from DarrylBayliss/master

Remove unneeded CFStringRef allocations in CFURL.
  • Loading branch information...
phausler committed Jan 6, 2016
2 parents c68e227 + 8297df2 commit 231dae16c0173a6dd3d23bf048cb19ff751bf3ee
Showing with 4 additions and 4 deletions.
  1. +4 −4 CoreFoundation/URL.subproj/CFURL.c
@@ -1157,10 +1157,10 @@ CFStringRef CFURLCreateStringByReplacingPercentEscapes(CFAllocatorRef alloc, CF
newStr = CFStringCreateMutable(alloc, length);
}
if (percentRange.location - mark > 0) {
- // FIXME: The creation of this temporary string is unfortunate.
- CFStringRef substring = CFStringCreateWithSubstring(alloc, originalString, CFRangeMake(mark, percentRange.location - mark));
- CFStringAppend(newStr, substring);
- CFRelease(substring);
+ CFRange charRange = CFRangeMake(mark, percentRange.location - mark);
+ UniChar charBuffer[charRange.length];
+ CFStringGetCharacters(originalString, charRange, charBuffer);
+ CFStringAppendCharacters(newStr, charBuffer, charRange.length);
}
CFStringAppend(newStr, escapedStr);
if (escapedStr) {

0 comments on commit 231dae1

Please sign in to comment.