mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 09:04:13 +00:00
optimisation for adding large ranges of characters.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@29982 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
cef862d077
commit
adb3c1b275
2 changed files with 57 additions and 13 deletions
|
@ -1,3 +1,8 @@
|
|||
2010-03-16 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSCharacterSet.m: Optimise for cases when huge ranges of
|
||||
characters are added to a set (as suggested by Fred).
|
||||
|
||||
2010-03-15 Adam Fedor <fedor@mallory>
|
||||
|
||||
Source/Additions/NSFileHandle+GNUstepBase.m: Define INADDR_NONE
|
||||
|
@ -5,7 +10,8 @@
|
|||
|
||||
2010-03-15 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/NSString.m (-initWithCoder:): Handle format used for XIB encoding.
|
||||
* Source/NSString.m (-initWithCoder:): Handle format used for
|
||||
XIB encoding.
|
||||
|
||||
2010-03-14 Adam Fedor <fedor@mallory>
|
||||
|
||||
|
|
|
@ -254,26 +254,61 @@
|
|||
|
||||
- (void) addCharactersInRange: (NSRange)aRange
|
||||
{
|
||||
unsigned i;
|
||||
NSUInteger i;
|
||||
NSUInteger m;
|
||||
NSUInteger b;
|
||||
|
||||
if (NSMaxRange(aRange) > UNICODE_MAX)
|
||||
m = NSMaxRange(aRange);
|
||||
if (m > UNICODE_MAX)
|
||||
{
|
||||
[NSException raise:NSInvalidArgumentException
|
||||
format:@"Specified range exceeds character set"];
|
||||
/* NOT REACHED */
|
||||
}
|
||||
|
||||
for (i = aRange.location; i < NSMaxRange(aRange); i++)
|
||||
else if (m < 1)
|
||||
{
|
||||
unsigned byte = i/8;
|
||||
return;
|
||||
}
|
||||
|
||||
while (byte >= _length)
|
||||
/* Make space if needed.
|
||||
*/
|
||||
b = (m - 1) / 8;
|
||||
if (b >= _length)
|
||||
{
|
||||
while (b >= _length)
|
||||
{
|
||||
[_obj setLength: _length + BITMAP_SIZE];
|
||||
_length += BITMAP_SIZE;
|
||||
_data = [_obj mutableBytes];
|
||||
}
|
||||
SETBIT(_data[byte], i % 8);
|
||||
[_obj setLength: _length];
|
||||
_data = [_obj mutableBytes];
|
||||
}
|
||||
|
||||
/* Fill the first byte in the range.
|
||||
*/
|
||||
i = aRange.location;
|
||||
b = i / 8;
|
||||
while (i % 8 != 0 && i < m)
|
||||
{
|
||||
SETBIT(_data[b], i % 8);
|
||||
i++;
|
||||
}
|
||||
|
||||
/* Set any complete bytes in the range.
|
||||
*/
|
||||
b = (m - i) / 8;
|
||||
if (b > 0)
|
||||
{
|
||||
memset(&_data[i / 8], 0xff, b);
|
||||
i += b * 8;
|
||||
}
|
||||
|
||||
/* Partial set of any bits needed in the last byte.
|
||||
*/
|
||||
b = i / 8;
|
||||
while (i < m)
|
||||
{
|
||||
SETBIT(_data[b], i % 8);
|
||||
i++;
|
||||
}
|
||||
_known = 0; // Invalidate cache
|
||||
}
|
||||
|
@ -314,10 +349,13 @@
|
|||
+ (second - 0xdc00) + 0x0010000;
|
||||
}
|
||||
byte = letter/8;
|
||||
while (byte >= _length)
|
||||
if (byte >= _length)
|
||||
{
|
||||
[_obj setLength: _length + BITMAP_SIZE];
|
||||
_length += BITMAP_SIZE;
|
||||
while (byte >= _length)
|
||||
{
|
||||
_length += BITMAP_SIZE;
|
||||
}
|
||||
[_obj setLength: _length];
|
||||
_data = [_obj mutableBytes];
|
||||
}
|
||||
SETBIT(_data[byte], letter % 8);
|
||||
|
|
Loading…
Reference in a new issue