diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2004-05-03 20:42:32 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2004-05-03 20:42:32 (GMT) |
commit | 5719061f35a9147b38a587af8af5c0e41b80c229 (patch) | |
tree | 6f02a684fa856fff66d6044cfe7d8d4b95c9b371 /src/H5FL.c | |
parent | 19f9a72e54dd8b2da56d03e6ff9e59d786820a09 (diff) | |
download | hdf5-5719061f35a9147b38a587af8af5c0e41b80c229.zip hdf5-5719061f35a9147b38a587af8af5c0e41b80c229.tar.gz hdf5-5719061f35a9147b38a587af8af5c0e41b80c229.tar.bz2 |
[svn-r8475] 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
Diffstat (limited to 'src/H5FL.c')
-rw-r--r-- | src/H5FL.c | 62 |
1 files changed, 36 insertions, 26 deletions
@@ -26,14 +26,17 @@ * move frequently accessed free lists to the head of the queue. */ +/* Pablo information */ +/* (Put before include files to avoid problems with inline functions) */ +#define PABLO_MASK H5FL_mask + /* #define H5FL_DEBUG */ -#include "H5private.h" /*library */ -#include "H5Eprivate.h" /*error handling */ -#include "H5MMprivate.h" /*Core memory management */ -#include "H5FLprivate.h" /*Priority queues */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5MMprivate.h" /* Memory management */ -#define PABLO_MASK H5FL_mask static int interface_initialize_g = 0; #define INTERFACE_INIT NULL @@ -547,36 +550,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); + 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() */ |