Small optimisation for creating NSString from UTF8 C string

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@38539 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2015-05-25 11:11:24 +00:00
parent 50d5d7789b
commit 1c74bc231b
3 changed files with 70 additions and 3 deletions

View file

@ -981,7 +981,14 @@ GSICUCollatorOpen(NSStringCompareOptions mask, NSLocale *locale)
if (NULL == bytes)
[NSException raise: NSInvalidArgumentException
format: @"[NSString+stringWithUTF8String:]: NULL cString"];
obj = [self allocWithZone: NSDefaultMallocZone()];
if (self == NSStringClass)
{
obj = defaultPlaceholderString;
}
else
{
obj = [self allocWithZone: NSDefaultMallocZone()];
}
obj = [obj initWithUTF8String: bytes];
return AUTORELEASE(obj);
}