mirror of
https://github.com/gnustep/libs-performance.git
synced 2025-06-04 10:30:55 +00:00
Tidy/simplify a little
This commit is contained in:
parent
7d78333d26
commit
4f8abe62dd
2 changed files with 36 additions and 21 deletions
|
@ -338,6 +338,13 @@ GSLinkedListRemove(GSListLink *link, GSLinkedList *list);
|
||||||
*/
|
*/
|
||||||
- (GSListLink*) addObject: (id)anObject;
|
- (GSListLink*) addObject: (id)anObject;
|
||||||
|
|
||||||
|
/** Adds an link to the list of unused links in the store.
|
||||||
|
* Raises an NSInvalidArgumentException if the link is still in use
|
||||||
|
* or if it is not of the class used by this instance.
|
||||||
|
* Calls GSLinkStoreConsumeLink() to add a usable link ot the store.
|
||||||
|
*/
|
||||||
|
- (void) consumeLink: (GSListLink*)link;
|
||||||
|
|
||||||
/** Returns the first (head) object in the list or nil if the list is empty.
|
/** Returns the first (head) object in the list or nil if the list is empty.
|
||||||
*/
|
*/
|
||||||
- (id) firstObject;
|
- (id) firstObject;
|
||||||
|
|
|
@ -377,20 +377,17 @@ GSLinkedListInsertAfter(GSListLink *link, GSLinkedList *list, GSListLink *at)
|
||||||
{
|
{
|
||||||
at = list->tail;
|
at = list->tail;
|
||||||
}
|
}
|
||||||
link->next = at ? at->next : nil;
|
link->next = at->next;
|
||||||
if (nil == link->next)
|
link->previous = at;
|
||||||
|
if (at->next)
|
||||||
|
{
|
||||||
|
at->next->previous = link;
|
||||||
|
}
|
||||||
|
at->next = link;
|
||||||
|
if (list->tail == at)
|
||||||
{
|
{
|
||||||
list->tail = link;
|
list->tail = link;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
link->next->previous = link;
|
|
||||||
}
|
|
||||||
if (at)
|
|
||||||
{
|
|
||||||
at->next = link;
|
|
||||||
}
|
|
||||||
link->previous = at;
|
|
||||||
}
|
}
|
||||||
link->owner = list;
|
link->owner = list;
|
||||||
list->count++;
|
list->count++;
|
||||||
|
@ -410,16 +407,16 @@ GSLinkedListInsertBefore(GSListLink *link, GSLinkedList *list, GSListLink *at)
|
||||||
at = list->head;
|
at = list->head;
|
||||||
}
|
}
|
||||||
link->previous = at->previous;
|
link->previous = at->previous;
|
||||||
if (nil == link->previous)
|
link->next = at;
|
||||||
|
if (at->previous)
|
||||||
|
{
|
||||||
|
at->previous->next = link;
|
||||||
|
}
|
||||||
|
at->previous = link;
|
||||||
|
if (list->head == at)
|
||||||
{
|
{
|
||||||
list->head = link;
|
list->head = link;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
link->previous->next = link;
|
|
||||||
}
|
|
||||||
at->previous = link;
|
|
||||||
link->next = at;
|
|
||||||
}
|
}
|
||||||
link->owner = list;
|
link->owner = list;
|
||||||
list->count++;
|
list->count++;
|
||||||
|
@ -448,7 +445,7 @@ GSLinkedListRemove(GSListLink *link, GSLinkedList *list)
|
||||||
list->tail->next = nil;
|
list->tail->next = nil;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (nil != link->next)
|
else
|
||||||
{
|
{
|
||||||
link->next->previous = link->previous;
|
link->next->previous = link->previous;
|
||||||
}
|
}
|
||||||
|
@ -523,6 +520,17 @@ GSLinkedListMoveToTail(GSListLink *link, GSLinkedList *list)
|
||||||
return GSLinkStoreInsertObjectAfter(anObject, self, tail);
|
return GSLinkStoreInsertObjectAfter(anObject, self, tail);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) consumeLink: (GSListLink*)link
|
||||||
|
{
|
||||||
|
NSAssert(link, NSInvalidArgumentException);
|
||||||
|
NSAssert(nil == link->previous, NSInvalidArgumentException);
|
||||||
|
NSAssert(nil == link->next, NSInvalidArgumentException);
|
||||||
|
NSAssert(nil == link->owner, NSInvalidArgumentException);
|
||||||
|
NSAssert(nil == link->item, NSInvalidArgumentException);
|
||||||
|
NSAssert([link class] == linkClass, NSInvalidArgumentException);
|
||||||
|
GSLinkStoreConsumeLink(self, link);
|
||||||
|
}
|
||||||
|
|
||||||
- (void) dealloc
|
- (void) dealloc
|
||||||
{
|
{
|
||||||
[self empty];
|
[self empty];
|
||||||
|
@ -626,7 +634,7 @@ GSLinkStoreInsertObjectAfter(
|
||||||
GSListLink *link = GSLinkStoreProvideLink(list);
|
GSListLink *link = GSLinkStoreProvideLink(list);
|
||||||
|
|
||||||
link->item = RETAIN(anObject);
|
link->item = RETAIN(anObject);
|
||||||
GSLinkedListInsertAfter(link, list, (nil == at) ? list->tail : at);
|
GSLinkedListInsertAfter(link, list, at);
|
||||||
return link;
|
return link;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -637,7 +645,7 @@ GSLinkStoreInsertObjectBefore(
|
||||||
GSListLink *link = GSLinkStoreProvideLink(list);
|
GSListLink *link = GSLinkStoreProvideLink(list);
|
||||||
|
|
||||||
link->item = RETAIN(anObject);
|
link->item = RETAIN(anObject);
|
||||||
GSLinkedListInsertBefore(link, list, (nil == at) ? list->head : at);
|
GSLinkedListInsertBefore(link, list, at);
|
||||||
return link;
|
return link;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue