revealed that this function was getting used super heavily.
* tools.c: removed the older, slower string tokenizer functions that
weren't getting used anymore.
$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.
Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
* Initial CVS import
+
#define CS_POSTING 4 /* Posting */
struct CitContext *MyContext(void);
-#define CC ((struct CitContext *)MyContext())
+#define CC MyContext()
extern struct CitContext *ContextList;
extern int ScheduledShutdown;
* 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)
+ );
}
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);
}
-/* 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 */
}
-/*
- * 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<strlen(source); ++i) {
- if (source[i]==separator) {
- ++curr_parm;
- }
- else if (curr_parm == parmnum) {
- dest[len+1] = 0;
- dest[len++] = source[i];
- }
- }
-}
-
-
-
-/* remove_token_fast() - a tokenizer that kills, maims, and destroys fast */
+/* remove_token() - a tokenizer that kills, maims, and destroys fast */
void remove_token(char *source, unsigned long parmnum, char separator)
{
char *d, *s; /* dest, source */
}
-/*
- * remove_token() - a tokenizer that kills, maims, and destroys
- */
-void remove_token_old(char *source, int parmnum, char separator)
-{
- int i;
- int len;
- int curr_parm;
- int start, end;
-
- len = 0;
- curr_parm = 0;
- start = (-1);
- end = (-1);
-
- if (strlen(source)==0) {
- return;
- }
-
- for (i=0; i<strlen(source); ++i) {
- if ( (start < 0) && (curr_parm == parmnum) ) {
- start = i;
- }
-
- if ( (end < 0) && (curr_parm == (parmnum+1)) ) {
- end = i;
- }
-
- if (source[i]==separator) {
- ++curr_parm;
- }
- }
-
- if (end < 0) end = strlen(source);
- strcpy(&source[start], &source[end]);
-}
-
-
-
-
/*
* extract_int() - extract an int parm w/o supplying a buffer
*/