DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://issues.apache.org/bugzilla/show_bug.cgi?id=29640>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=29640 Changes to apache core to allow sorted array elements Summary: Changes to apache core to allow sorted array elements Product: Apache httpd-1.3 Version: HEAD Platform: All OS/Version: Other Status: NEW Severity: Enhancement Priority: Other Component: core AssignedTo: [email protected] ReportedBy: [EMAIL PROTECTED] CC: [EMAIL PROTECTED] I'm working on some changes to modules that increase performance characteristics by using sorted arrays to allow for binary searches. I have cerated a function for generically sorting array elements. This should be added alloc.c as that seems the logical place to add it in. Following is the diff for alloc.c from version 1.3.26. As this is an entirely new function it is rather easy to add to any 1.3.X version of Apache : 1239,1285d1238 < API_EXPORT(void) ap_array_sort(array_header *arr, < int (*item_compare_callback)(void*, void*)) < { < int i = 0; < char *tempory_element = ap_palloc(arr->pool, arr->elt_size); < < /* If there are less than 2 elements, it is already sorted */ < < if (arr->nelts < 2) { < return; < } < < < /* Do a simple bubble sort. Not the most efficient, < but this should only happen once. */ < < for (;i < arr->nelts;i++) { < int j = 0; < int was_there_a_switch = 0; < < for (;j < arr->nelts - 1;j++) { < < if ((*item_compare_callback)( < (void*)(arr->elts + (j * arr->elt_size)), < (void*)(arr->elts + ((j + 1)* arr->elt_size)))) { < < memcpy(tempory_element, arr->elts + (j * arr->elt_size), < arr->elt_size); < memcpy(arr->elts + (j * arr->elt_size), < arr->elts + ((j + 1) * arr->elt_size), arr->elt_size); < memcpy(arr->elts + ((j + 1) * arr->elt_size), < tempory_element, arr->elt_size); < was_there_a_switch = 1; < } < } < < /* If nothing was changed then the sort is now complete */ < < if (was_there_a_switch == 0) { < i = arr->nelts; < } < } < return; < } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
