mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 00:30:53 +00:00
Minor optimisation for utf-8 string initialisation
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@23098 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
12e5d0d9da
commit
2c0ee96dfe
2 changed files with 47 additions and 2 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2006-06-22 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
* Source/GSString.m: small optimisation for initialisation with
|
||||||
|
unicode data which happens to be just ascii.
|
||||||
|
|
||||||
2006-06-20 Richard Frith-Macdonald <rfm@gnu.org>
|
2006-06-20 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Source/GSHTTPDigest.m: deleted
|
* Source/GSHTTPDigest.m: deleted
|
||||||
|
|
|
@ -506,7 +506,27 @@ fixBOM(unsigned char **bytes, unsigned *length, BOOL *shouldFree,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (encoding != internalEncoding && GSIsByteEncoding(encoding) == YES)
|
if (encoding == NSUTF8StringEncoding)
|
||||||
|
{
|
||||||
|
unsigned i;
|
||||||
|
|
||||||
|
for (i = 0; i < length; i++)
|
||||||
|
{
|
||||||
|
if ((chars.c)[i] > 127)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (i == length)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* This is actually ASCII data ... so we can just store it as if
|
||||||
|
* in the internal 8bit encoding scheme.
|
||||||
|
*/
|
||||||
|
encoding = internalEncoding;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (encoding != internalEncoding && GSIsByteEncoding(encoding) == YES)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
|
@ -3653,7 +3673,27 @@ NSAssert(_flags.free == 1 && _zone != 0, NSInternalInconsistencyException);
|
||||||
chars = (unsigned char*)bytes;
|
chars = (unsigned char*)bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (encoding != internalEncoding && GSIsByteEncoding(encoding) == YES)
|
if (encoding == NSUTF8StringEncoding)
|
||||||
|
{
|
||||||
|
unsigned i;
|
||||||
|
|
||||||
|
for (i = 0; i < length; i++)
|
||||||
|
{
|
||||||
|
if (chars[i] > 127)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (i == length)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* This is actually ASCII data ... so we can just store it as if
|
||||||
|
* in the internal 8bit encoding scheme.
|
||||||
|
*/
|
||||||
|
encoding = internalEncoding;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (encoding != internalEncoding && GSIsByteEncoding(encoding) == YES)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue