mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
More optimisation
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@28333 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
39839cb227
commit
025788b20a
2 changed files with 23 additions and 12 deletions
|
@ -2,6 +2,7 @@
|
|||
|
||||
* Source/Additions/Unicode.m: Optimise case where we are converting
|
||||
from unicode to latin1 or ascii.
|
||||
* Source/GSString.m: Optimise -hash method of NXConstantString too.
|
||||
|
||||
2009-06-06 Wolfgang Lux <wolfgang.lux@gmail.com>
|
||||
|
||||
|
|
|
@ -5053,23 +5053,33 @@ NSAssert(_flags.owned == 1 && _zone != 0, NSInternalInconsistencyException);
|
|||
|
||||
if (len > 0)
|
||||
{
|
||||
const unsigned char *p;
|
||||
unsigned char_count = 0;
|
||||
register const unsigned char *p;
|
||||
register unsigned index = 0;
|
||||
|
||||
p = _self->_contents.c;
|
||||
while (char_count++ < len)
|
||||
if (internalEncoding == NSISOLatin1StringEncoding)
|
||||
{
|
||||
unichar u = *p++;
|
||||
|
||||
if (u > 127 && internalEncoding != NSISOLatin1StringEncoding)
|
||||
while (index < len)
|
||||
{
|
||||
unsigned char c = (unsigned char)u;
|
||||
unsigned int s = 1;
|
||||
unichar *d = &u;
|
||||
|
||||
GSToUnicode(&d, &s, &c, 1, internalEncoding, 0, 0);
|
||||
ret = (ret << 5) + ret + p[index++];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while (index < len)
|
||||
{
|
||||
unichar u = p[index++];
|
||||
|
||||
if (u > 127)
|
||||
{
|
||||
unsigned char c = (unsigned char)u;
|
||||
unsigned int s = 1;
|
||||
unichar *d = &u;
|
||||
|
||||
GSToUnicode(&d, &s, &c, 1, internalEncoding, 0, 0);
|
||||
}
|
||||
ret = (ret << 5) + ret + u;
|
||||
}
|
||||
ret = (ret << 5) + ret + u;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in a new issue