From 5f736b4bed07547c7de06f2ffb3945320de1d7d0 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Mon, 3 May 2004 15:42:35 -0500 Subject: [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 --- src/H5FL.c | 47 +++++++++++++++++++++++++++-------------------- 1 file 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() */ -- cgit v0.12