]> code.citadel.org Git - citadel.git/blobdiff - citadel/sysdep.c
* sysdep.c: optimized MyContext() a bit, and inlined it. A little profiling
[citadel.git] / citadel / sysdep.c
index 243c299979dbac4ef69a089f1c23a82cb352b6a1..bc3db99164f10991ec1dd8eb2054fe7f095bbc0d 100644 (file)
@@ -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)
+       );
 }