more utf8 optimisation

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@38542 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2015-05-25 17:55:51 +00:00
parent 325689b04f
commit 8d31d3a100

View file

@ -1072,7 +1072,7 @@ tsbytes(uintptr_t s, char *buf)
/** /**
* Constructs a tiny string. * Constructs a tiny string.
*/ */
static id static inline id
createTinyString(const char *str, int length) createTinyString(const char *str, int length)
{ {
unsigned int i; unsigned int i;
@ -1112,7 +1112,7 @@ createTinyString(const char *str, int length)
return (id)s; return (id)s;
} }
#else #else
static id static inline id
createTinyString(const char *str, int length) createTinyString(const char *str, int length)
{ {
return nil; return nil;
@ -1712,9 +1712,15 @@ fixBOM(unsigned char **bytes, NSUInteger*length, BOOL *owned,
if (YES == ascii) if (YES == ascii)
{ {
me = (GSStr)newCInline(length, myZone); id o = createTinyString(bytes, length);
memcpy(me->_contents.c, bytes, length);
return (id)me; if (nil == o)
{
me = (GSStr)newCInline(length, myZone);
memcpy(me->_contents.c, bytes, length);
o = (id)me;
}
return o;
} }
else else
{ {