diff --git a/ChangeLog b/ChangeLog index 169ce133a..f2348630b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,8 @@ it needed more data even though it had actually completed. * Source/NSException.m: Don't add stacktrace information if we are not building with debug on. + * Source/GSString.m: Minor optimisation ... return @"" for all + substrings with a zero length range. 2006-05-22 Richard Frith-Macdonald diff --git a/Source/GSString.m b/Source/GSString.m index f5f22b33b..145d771bd 100644 --- a/Source/GSString.m +++ b/Source/GSString.m @@ -2455,6 +2455,10 @@ substring_c(GSStr self, NSRange aRange) @defs(GSCSubString) } *o; + if (aRange.length == 0) + { + return @""; + } o = (typeof(o))NSAllocateObject(GSCSubStringClass, 0, NSDefaultMallocZone()); o->_contents.c = self->_contents.c + aRange.location; @@ -2473,6 +2477,10 @@ substring_u(GSStr self, NSRange aRange) @defs(GSUnicodeSubString) } *o; + if (aRange.length == 0) + { + return @""; + } o = (typeof(o))NSAllocateObject(GSUnicodeSubStringClass, 0, NSDefaultMallocZone()); o->_contents.u = self->_contents.u + aRange.location; @@ -4127,6 +4135,10 @@ agree, create a new GSUnicodeInlineString otherwise. { GS_RANGE_CHECK(aRange, _count); + if (aRange.length == 0) + { + return @""; + } if (_flags.wide == 1) { struct { @@ -4164,6 +4176,10 @@ agree, create a new GSUnicodeInlineString otherwise. { GS_RANGE_CHECK(aRange, _count); + if (aRange.length == 0) + { + return @""; + } if (_flags.wide == 1) { struct {