From: Art Cancro Date: Tue, 1 Apr 2003 05:01:08 +0000 (+0000) Subject: * sysdep.c: optimized MyContext() a bit, and inlined it. A little profiling X-Git-Tag: v7.86~5950 X-Git-Url: https://code.citadel.org/?a=commitdiff_plain;h=4815d0f0d89043e4216df680a4ea792b1efeb136;p=citadel.git * sysdep.c: optimized MyContext() a bit, and inlined it. A little profiling revealed that this function was getting used super heavily. * tools.c: removed the older, slower string tokenizer functions that weren't getting used anymore. --- diff --git a/citadel/ChangeLog b/citadel/ChangeLog index 97f1cc888..1c9357ed3 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,4 +1,10 @@ $Log$ + Revision 605.31 2003/04/01 05:01:08 ajc + * sysdep.c: optimized MyContext() a bit, and inlined it. A little profiling + revealed that this function was getting used super heavily. + * tools.c: removed the older, slower string tokenizer functions that + weren't getting used anymore. + Revision 605.30 2003/03/31 04:55:58 ajc * Repaired the formatting of text/plain messages with blank lines. @@ -4606,3 +4612,4 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant Fri Jul 10 1998 Art Cancro * Initial CVS import + diff --git a/citadel/server.h b/citadel/server.h index 1866d3c3d..d99be8ddf 100644 --- a/citadel/server.h +++ b/citadel/server.h @@ -152,7 +152,7 @@ enum { #define CS_POSTING 4 /* Posting */ struct CitContext *MyContext(void); -#define CC ((struct CitContext *)MyContext()) +#define CC MyContext() extern struct CitContext *ContextList; extern int ScheduledShutdown; diff --git a/citadel/sysdep.c b/citadel/sysdep.c index 243c29997..bc3db9916 100644 --- a/citadel/sysdep.c +++ b/citadel/sysdep.c @@ -408,12 +408,14 @@ int ig_uds_server(char *sockpath, int queue_len) * Return a pointer to the CitContext structure bound to the thread which * called this function. If there's no such binding (for example, if it's * called by the housekeeper thread) then a generic 'master' CC is returned. + * + * It's inlined because it's used *VERY* frequently. */ -struct CitContext *MyContext(void) { - struct CitContext *retCC; - retCC = (struct CitContext *) pthread_getspecific(MyConKey); - if (retCC == NULL) retCC = &masterCC; - return(retCC); +inline struct CitContext *MyContext(void) { + return ((pthread_getspecific(MyConKey) == NULL) + ? &masterCC + : (struct CitContext *) pthread_getspecific(MyConKey) + ); } diff --git a/citadel/sysdep_decls.h b/citadel/sysdep_decls.h index 023ee935a..406e8f689 100644 --- a/citadel/sysdep_decls.h +++ b/citadel/sysdep_decls.h @@ -17,7 +17,7 @@ void begin_critical_section (int which_one); void end_critical_section (int which_one); int ig_tcp_server (int port_number, int queue_len); int ig_uds_server(char *sockpath, int queue_len); -struct CitContext *MyContext (void); +inline struct CitContext *MyContext (void); struct CitContext *CreateNewContext (void); void InitMyContext (struct CitContext *con); void client_write (char *buf, int nbytes); diff --git a/citadel/tools.c b/citadel/tools.c index c4a3ca430..a241d2907 100644 --- a/citadel/tools.c +++ b/citadel/tools.c @@ -86,7 +86,7 @@ int num_tokens(const char *source, char tok) { } -/* extract_token_fast() - a smarter string tokenizer */ +/* extract_token() - a smarter string tokenizer */ void extract_token(char *dest, const char *source, unsigned long parmnum, char separator) { char *d; /* dest */ @@ -117,37 +117,7 @@ void extract_token(char *dest, const char *source, unsigned long parmnum, char s } -/* - * extract_token() - a smarter string tokenizer - */ -void extract_token_old(char *dest, const char *source, unsigned long parmnum, char separator) -{ - int i; - int len; - int curr_parm; - - strcpy(dest,""); - len = 0; - curr_parm = 0; - - if (strlen(source)==0) { - return; - } - - for (i=0; i