mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Minor optimization.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@10261 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
3425151867
commit
aa4ed3f15e
2 changed files with 37 additions and 5 deletions
|
@ -1,3 +1,9 @@
|
|||
2001-06-26 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSSerializer.m: While deserializing, check strings to see
|
||||
if they are really unicode, and create cStrings if they are not.
|
||||
Minor memory usage optimisation.
|
||||
|
||||
2001-06-21 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSConnection.m: Change some deprecated runloop methods for
|
||||
|
|
|
@ -475,15 +475,41 @@ deserializeFromInfo(_NSDeserializerInfo* info)
|
|||
|
||||
case ST_STRING:
|
||||
{
|
||||
GSUnicodeString *s;
|
||||
unichar *b;
|
||||
NSString *s;
|
||||
unichar *b;
|
||||
unsigned i;
|
||||
|
||||
b = NSZoneMalloc(NSDefaultMallocZone(), size*sizeof(unichar));
|
||||
(*info->debImp)(info->data, debSel, b, size*sizeof(unichar),
|
||||
info->cursor);
|
||||
s = (GSUnicodeString*)NSAllocateObject(USCls,
|
||||
0, NSDefaultMallocZone());
|
||||
s = (*usInitImp)(s, usInitSel, b, size, YES);
|
||||
|
||||
/*
|
||||
* Check to see if this really IS unicode ... if not, use a cString
|
||||
*/
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
if (b[i] > 127)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == size)
|
||||
{
|
||||
char *p = (char*)b;
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
p[i] = (char)b[i];
|
||||
}
|
||||
p = NSZoneRealloc(NSDefaultMallocZone(), b, size);
|
||||
s = (NSString*)NSAllocateObject(CSCls, 0, NSDefaultMallocZone());
|
||||
s = (*csInitImp)(s, csInitSel, b, size-1, YES);
|
||||
}
|
||||
else
|
||||
{
|
||||
s = (NSString*)NSAllocateObject(USCls, 0, NSDefaultMallocZone());
|
||||
s = (*usInitImp)(s, usInitSel, b, size, YES);
|
||||
}
|
||||
|
||||
/*
|
||||
* If we are supposed to be doing uniquing of strings, handle it.
|
||||
|
|
Loading…
Reference in a new issue