From 8d31d3a100a242033e7512d4114dfaf9539e97b6 Mon Sep 17 00:00:00 2001 From: rfm Date: Mon, 25 May 2015 17:55:51 +0000 Subject: [PATCH] more utf8 optimisation git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@38542 72102866-910b-0410-8b05-ffd578937521 --- Source/GSString.m | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Source/GSString.m b/Source/GSString.m index 6f76273fc..ecb664c31 100644 --- a/Source/GSString.m +++ b/Source/GSString.m @@ -1072,7 +1072,7 @@ tsbytes(uintptr_t s, char *buf) /** * Constructs a tiny string. */ -static id +static inline id createTinyString(const char *str, int length) { unsigned int i; @@ -1112,7 +1112,7 @@ createTinyString(const char *str, int length) return (id)s; } #else -static id +static inline id createTinyString(const char *str, int length) { return nil; @@ -1712,9 +1712,15 @@ fixBOM(unsigned char **bytes, NSUInteger*length, BOOL *owned, if (YES == ascii) { - me = (GSStr)newCInline(length, myZone); - memcpy(me->_contents.c, bytes, length); - return (id)me; + id o = createTinyString(bytes, length); + + if (nil == o) + { + me = (GSStr)newCInline(length, myZone); + memcpy(me->_contents.c, bytes, length); + o = (id)me; + } + return o; } else {