mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-16 19:00:47 +00:00
further fast enumeration bugfixes from david.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@27774 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
d64071198b
commit
a885b64dba
3 changed files with 16 additions and 6 deletions
|
@ -1,6 +1,12 @@
|
||||||
|
2009-02-04 David Chisnall <csdavec@swansea.ac.uk>
|
||||||
|
|
||||||
|
* Source/GSArray.m: Firther fast enumeration bugfixes.
|
||||||
|
* Source/GSEnumerator.m: ditto.
|
||||||
|
|
||||||
2009-02-03 Richard Frith-Macdonald <rfm@gnu.org>
|
2009-02-03 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Source/NSZone.m: restore binary compatibility with earlier code.
|
* Source/NSZone.m: restore binary compatibility with earlier code.
|
||||||
|
Thanks to David Chisnall for the idea.
|
||||||
|
|
||||||
2009-01-30 Richard Frith-Macdonald <rfm@gnu.org>
|
2009-01-30 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
|
|
@ -373,8 +373,11 @@ static Class GSInlineArrayClass;
|
||||||
count: (NSUInteger)len
|
count: (NSUInteger)len
|
||||||
{
|
{
|
||||||
/* For immutable arrays we can return the contents pointer directly. */
|
/* For immutable arrays we can return the contents pointer directly. */
|
||||||
state->itemsPtr = _contents_array;
|
NSUInteger count = _count - state->state;
|
||||||
return _count;
|
state->mutationsPtr = (unsigned long *)self;
|
||||||
|
state->itemsPtr = _contents_array + state->state;
|
||||||
|
state->state += count;
|
||||||
|
return count;
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@ -903,15 +906,15 @@ static Class GSInlineArrayClass;
|
||||||
* iteration. If it changes during the iteration then
|
* iteration. If it changes during the iteration then
|
||||||
* objc_enumerationMutation() will be called, throwing an exception.
|
* objc_enumerationMutation() will be called, throwing an exception.
|
||||||
*/
|
*/
|
||||||
state->mutationsPtr = (unsigned long*)_version;
|
state->mutationsPtr = (unsigned long *)&_version;
|
||||||
count = MIN(len, _count - state->state);
|
count = MIN(len, _count - state->state);
|
||||||
/* If a mutation has occurred then it's possible that we are being asked to
|
/* If a mutation has occurred then it's possible that we are being asked to
|
||||||
* get objects from after the end of the array. Don't pass negative values
|
* get objects from after the end of the array. Don't pass negative values
|
||||||
* to memcpy.
|
* to memcpy.
|
||||||
*/
|
*/
|
||||||
if (count <= 0)
|
if (count >= 0)
|
||||||
{
|
{
|
||||||
memcpy(stackbuf, _contents_array, count);
|
memcpy(stackbuf, _contents_array + state->state, count * sizeof(id));
|
||||||
state->state += count;
|
state->state += count;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -81,6 +81,8 @@
|
||||||
IMP nextObject = [self methodForSelector: @selector(nextObject)];
|
IMP nextObject = [self methodForSelector: @selector(nextObject)];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
state->itemsPtr = stackbuf;
|
||||||
|
state->mutationsPtr = (unsigned long*)self;
|
||||||
for (i = 0; i < len; i++)
|
for (i = 0; i < len; i++)
|
||||||
{
|
{
|
||||||
id next = nextObject(self, @selector(nextObject));
|
id next = nextObject(self, @selector(nextObject));
|
||||||
|
@ -91,7 +93,6 @@
|
||||||
}
|
}
|
||||||
*(stackbuf+i) = next;
|
*(stackbuf+i) = next;
|
||||||
}
|
}
|
||||||
state->itemsPtr = stackbuf;
|
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
Loading…
Reference in a new issue