about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-04-08 16:09:03 -0700
committerEric Wong <normalperson@yhbt.net>2009-04-08 16:09:03 -0700
commit9625ad39b73d3d1443ff097e9113d1ec9c9d5f00 (patch)
treea6f473a13b546fc2fb21ffc014a11159f5ebf367
parente5da852c365e3877ee57441b6fc6b336ab434817 (diff)
downloadunicorn-9625ad39b73d3d1443ff097e9113d1ec9c9d5f00.tar.gz
The build-time complexity was not worth the minor
performance improvement we could get for the average
case (and we can cut down the amount of comparisons
by putting frequent/required headers first).
-rw-r--r--ext/unicorn/http11/http11.c34
1 files changed, 0 insertions, 34 deletions
diff --git a/ext/unicorn/http11/http11.c b/ext/unicorn/http11/http11.c
index 421e4d5..995bf2a 100644
--- a/ext/unicorn/http11/http11.c
+++ b/ext/unicorn/http11/http11.c
@@ -111,21 +111,6 @@ static struct common_field common_http_fields[] = {
 # undef f
 };
 
-/*
- * qsort(3) and bsearch(3) improve average performance slightly, but may
- * not be worth it for lack of portability to certain platforms...
- */
-#if defined(HAVE_QSORT_BSEARCH)
-/* sort by length, then by name if there's a tie */
-static int common_field_cmp(const void *a, const void *b)
-{
-  struct common_field *cfa = (struct common_field *)a;
-  struct common_field *cfb = (struct common_field *)b;
-  signed long diff = cfa->len - cfb->len;
-  return diff ? diff : memcmp(cfa->name, cfb->name, cfa->len);
-}
-#endif /* HAVE_QSORT_BSEARCH */
-
 /* this function is not performance-critical */
 static void init_common_fields(void)
 {
@@ -146,28 +131,10 @@ static void init_common_fields(void)
     cf->value = rb_obj_freeze(cf->value);
     rb_global_variable(&cf->value);
   }
-
-#if defined(HAVE_QSORT_BSEARCH)
-  qsort(common_http_fields,
-        ARRAY_SIZE(common_http_fields),
-        sizeof(struct common_field),
-        common_field_cmp);
-#endif /* HAVE_QSORT_BSEARCH */
 }
 
 static VALUE find_common_field_value(const char *field, size_t flen)
 {
-#if defined(HAVE_QSORT_BSEARCH)
-  struct common_field key;
-  struct common_field *found;
-  key.name = field;
-  key.len = (signed long)flen;
-  found = (struct common_field *)bsearch(&key, common_http_fields,
-                                         ARRAY_SIZE(common_http_fields),
-                                         sizeof(struct common_field),
-                                         common_field_cmp);
-  return found ? found->value : Qnil;
-#else /* !HAVE_QSORT_BSEARCH */
   int i;
   struct common_field *cf = common_http_fields;
   for(i = 0; i < ARRAY_SIZE(common_http_fields); i++, cf++) {
@@ -175,7 +142,6 @@ static VALUE find_common_field_value(const char *field, size_t flen)
       return cf->value;
   }
   return Qnil;
-#endif /* !HAVE_QSORT_BSEARCH */
 }
 
 static void http_field(void *data, const char *field,