summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2004-05-03 20:42:35 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2004-05-03 20:42:35 (GMT)
commit5f736b4bed07547c7de06f2ffb3945320de1d7d0 (patch)
tree8a29c4d1102aad275aeeff9749288f4647b31ef4
parent8aef71afb7c4446c326c02292ec9206a4b873f08 (diff)
downloadhdf5-5f736b4bed07547c7de06f2ffb3945320de1d7d0.zip
hdf5-5f736b4bed07547c7de06f2ffb3945320de1d7d0.tar.gz
hdf5-5f736b4bed07547c7de06f2ffb3945320de1d7d0.tar.bz2
[svn-r8476] Purpose:
Code optimization Description: Improved LRU algorithm for locating blocks of the correct size in the block free-list Platforms tested: Solaris 2.7 (arabica) FreeBSD 4.9 (sleipnir) w/parallel too minor for h5committest
-rw-r--r--src/H5FL.c47
1 files changed, 27 insertions, 20 deletions
diff --git a/src/H5FL.c b/src/H5FL.c
index a2aae27..1d844b2 100644
--- a/src/H5FL.c
+++ b/src/H5FL.c
@@ -557,36 +557,43 @@ static H5FL_blk_node_t *
H5FL_blk_find_list(H5FL_blk_node_t **head, size_t size)
{
H5FL_blk_node_t *temp; /* Temp. pointer to node in the native list */
- H5FL_blk_node_t *ret_value;
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5FL_blk_find_list)
/* Find the correct free list */
temp=*head;
- while(temp!=NULL && temp->size!=size)
+
+ /* Check if the node is at the head of the list */
+ if(temp && temp->size!=size) {
temp=temp->next;
- /* If the free list exists, move it to the front of the queue, if it's not there already */
- if(temp!=NULL && temp!=*head) {
- /* Take the node found out of it's current position */
- if(temp->next==NULL) {
- temp->prev->next=NULL;
- } /* end if */
- else {
- temp->prev->next=temp->next;
- temp->next->prev=temp->prev;
- } /* end else */
+ while(temp!=NULL) {
+ /* Check if we found the correct node */
+ if(temp->size==size) {
+ /* Take the node found out of it's current position */
+ if(temp->next==NULL) {
+ temp->prev->next=NULL;
+ } /* end if */
+ else {
+ temp->prev->next=temp->next;
+ temp->next->prev=temp->prev;
+ } /* end else */
+
+ /* Move the found node to the head of the list */
+ temp->prev=NULL;
+ temp->next=*head;
+ (*head)->prev=temp;
+ *head=temp;
+
+ /* Get out */
+ break;
+ } /* end if */
- /* Move the found node to the head of the list */
- temp->prev=NULL;
- temp->next=*head;
- (*head)->prev=temp;
- *head=temp;
+ temp=temp->next;
+ } /* end while */
} /* end if */
- ret_value=temp;
-
- FUNC_LEAVE_NOAPI(ret_value)
+ FUNC_LEAVE_NOAPI(temp)
} /* end H5FL_blk_find_list() */