Looking at the node_addvalue() function, it manipulates a sorted linked list. Probably the simplest way to speed it up would be to insert an entire array of values at one time, which would reduce the need to scan the entire linked list from the start for each value. A better way would be to get rid of linked list structure in favor of something else, but that would require somewhat more major surgery.