mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-29 16:01:38 +00:00
minor optimisations
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@31433 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
52d7256b41
commit
42828af0cc
3 changed files with 182 additions and 50 deletions
|
@ -2824,6 +2824,12 @@ transmute(GSStr self, NSString *aString)
|
|||
setup(YES);
|
||||
}
|
||||
|
||||
- (id) copyWithZone: (NSZone*)z
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
return nil;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return a 28-bit hash value for the string contents - this
|
||||
* MUST match the algorithm used by the NSString base class.
|
||||
|
@ -2980,10 +2986,84 @@ transmute(GSStr self, NSString *aString)
|
|||
freeWhenDone: flag];
|
||||
}
|
||||
|
||||
- (id) copyWithZone: (NSZone*)z
|
||||
- (id) lowercaseString
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
return nil;
|
||||
if (_flags.wide == 1)
|
||||
{
|
||||
GSUnicodeInlineString *o;
|
||||
unsigned i;
|
||||
|
||||
o = (typeof(o))NSAllocateObject(GSUnicodeInlineStringClass,
|
||||
_count * sizeof(unichar), NSDefaultMallocZone());
|
||||
o->_contents.u = (unichar*)
|
||||
(((void*)o)+class_getInstanceSize(GSUnicodeInlineStringClass));
|
||||
i = o->_count = _count;
|
||||
while (i-- > 0)
|
||||
{
|
||||
o->_contents.u[i] = uni_tolower(_contents.u[i]);
|
||||
}
|
||||
o->_flags.wide = 1;
|
||||
o->_flags.owned = 1; // Ignored on dealloc, but means we own buffer
|
||||
return [(id)o autorelease];
|
||||
}
|
||||
else
|
||||
{
|
||||
GSCInlineString *o;
|
||||
unsigned i;
|
||||
|
||||
o = (typeof(o))NSAllocateObject(GSCInlineStringClass,
|
||||
_count, NSDefaultMallocZone());
|
||||
o->_contents.c = (unsigned char*)
|
||||
(((void*)o)+class_getInstanceSize(GSCInlineStringClass));
|
||||
i = o->_count = _count;
|
||||
while (i-- > 0)
|
||||
{
|
||||
o->_contents.c[i] = tolower(_contents.c[i]);
|
||||
}
|
||||
o->_flags.wide = 0;
|
||||
o->_flags.owned = 1; // Ignored on dealloc, but means we own buffer
|
||||
return [(id)o autorelease];
|
||||
}
|
||||
}
|
||||
|
||||
- (id) uppercaseString
|
||||
{
|
||||
if (_flags.wide == 1)
|
||||
{
|
||||
GSUnicodeInlineString *o;
|
||||
unsigned i;
|
||||
|
||||
o = (typeof(o))NSAllocateObject(GSUnicodeInlineStringClass,
|
||||
_count * sizeof(unichar), NSDefaultMallocZone());
|
||||
o->_contents.u = (unichar*)
|
||||
(((void*)o)+class_getInstanceSize(GSUnicodeInlineStringClass));
|
||||
i = o->_count = _count;
|
||||
while (i-- > 0)
|
||||
{
|
||||
o->_contents.u[i] = uni_toupper(_contents.u[i]);
|
||||
}
|
||||
o->_flags.wide = 1;
|
||||
o->_flags.owned = 1; // Ignored on dealloc, but means we own buffer
|
||||
return [(id)o autorelease];
|
||||
}
|
||||
else
|
||||
{
|
||||
GSCInlineString *o;
|
||||
unsigned i;
|
||||
|
||||
o = (typeof(o))NSAllocateObject(GSCInlineStringClass,
|
||||
_count, NSDefaultMallocZone());
|
||||
o->_contents.c = (unsigned char*)
|
||||
(((void*)o)+class_getInstanceSize(GSCInlineStringClass));
|
||||
i = o->_count = _count;
|
||||
while (i-- > 0)
|
||||
{
|
||||
o->_contents.c[i] = toupper(_contents.c[i]);
|
||||
}
|
||||
o->_flags.wide = 0;
|
||||
o->_flags.owned = 1; // Ignored on dealloc, but means we own buffer
|
||||
return [(id)o autorelease];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue