obCircle: I realized recently that get_id_by_name() searches the entire player_table for a string match. I've seen player_tables upwards of 1500, which means 1500 long string compares that I think are unnecessary. How about setting up a hash table with 200 entries based on the first 3 chars of the player's name? Also, add struct player_index_element *next to struct player_index_element. For example, we could use this instead: long get_id_by_name(char *name) { int i; struct player_index_element *tmp; one_argument(name, arg); i = (('z' - *arg) + ('z' - *(arg+1)) + ('z' - *(arg+3))) % 200; if(player_index[i] != NULL) for(tmp = player_index[i]; tmp, tmp = tmp->next) if(!strcmp(tmp->name, arg)) return(tmp->id); return(-1); } The code to build a hashed index is longer than I'm gonna attempt to write in my mailer, but you get the idea :) This would be really helpful for mobs and objects as well. It's gotta save heaps of search time in a big mud. Sam +-----------------------------------------------------------+ | Ensure that you have read the CircleMUD Mailing List FAQ: | | http://cspo.queensu.ca/~fletcher/Circle/list_faq.html | +-----------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/18/00 PST