]> granicus.if.org Git - apache/commitdiff
A very small optimization to the OLD_WRITE logic. This just makes us store
authorRyan Bloom <rbb@apache.org>
Tue, 11 Sep 2001 18:38:21 +0000 (18:38 +0000)
committerRyan Bloom <rbb@apache.org>
Tue, 11 Sep 2001 18:38:21 +0000 (18:38 +0000)
a pointer to the OLD_WRITE frec, and instead of using strcmp or strcasecmp,
we can just do a simple pointer comparison.  This optimization is also
available to other modules.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@91006 13f79535-47bb-0310-9956-ffa450edef68

include/http_protocol.h
include/util_filter.h
server/core.c
server/protocol.c
server/util_filter.c

index d3065f672c11f2784fa146ffcb318c62b3046051..b6073da0922ea69274865f15abdc8ecc4a85f42f 100644 (file)
@@ -74,6 +74,11 @@ extern "C" {
  * @package HTTP protocol handling
  */
 
+/* This is an optimization.  We keep a record of the filter_rec that
+ * stores the old_write filter, so that we can avoid strcmp's later.
+ */
+AP_DECLARE_DATA extern ap_filter_rec_t *ap_old_write_func;
+
 /*
  * Prototypes for routines which either talk directly back to the user,
  * or control the ones that eventually do.
index 7ba39b49153bfe1e73b06ddf085afe4080c9aaba..9dc061fb748208edde8a1e312d9ca7286170e93c 100644 (file)
@@ -300,7 +300,7 @@ AP_DECLARE(apr_status_t) ap_pass_brigade(ap_filter_t *filter, apr_bucket_brigade
  *        AP_FTYPE_CONNECTION
  * @see add_input_filter()
  */
-AP_DECLARE(void) ap_register_input_filter(const char *name,
+AP_DECLARE(ap_filter_rec_t *) ap_register_input_filter(const char *name,
                                          ap_in_filter_func filter_func,
                                          ap_filter_type ftype);
 /**
@@ -315,7 +315,7 @@ AP_DECLARE(void) ap_register_input_filter(const char *name,
  *              ::AP_FTYPE_CONNECTION
  * @see ap_add_output_filter()
  */
-AP_DECLARE(void) ap_register_output_filter(const char *name,
+AP_DECLARE(ap_filter_rec_t *) ap_register_output_filter(const char *name,
                                            ap_out_filter_func filter_func,
                                            ap_filter_type ftype);
 
index 0663e6b3a8cbd9c7ef3881581e841ab21ecb3a76..66398896457a2881991d184317e0dc1e3bc85603 100644 (file)
@@ -3419,8 +3419,8 @@ static void register_hooks(apr_pool_t *p)
     ap_register_output_filter("CORE", core_output_filter, AP_FTYPE_NETWORK);
     ap_register_output_filter("SUBREQ_CORE", ap_sub_req_output_filter, 
                               AP_FTYPE_CONTENT);
-    ap_register_output_filter("OLD_WRITE", ap_old_write_filter,
-                              AP_FTYPE_CONTENT - 1);
+    ap_old_write_func = ap_register_output_filter("OLD_WRITE", 
+                                   ap_old_write_filter, AP_FTYPE_CONTENT - 1);
 }
 
 AP_DECLARE_DATA module core_module = {
index 80fa2ee1912570da325e10ba1b9958eab057c2a3..336aec58250add0dd8beb47a565be58d14cf710d 100644 (file)
@@ -104,6 +104,8 @@ APR_HOOK_STRUCT(
            APR_HOOK_LINK(default_port)
 )
 
+AP_DECLARE_DATA ap_filter_rec_t *ap_old_write_func;
+
 /*
  * Builds the content-type that should be sent to the client from the
  * content-type specified.  The following rules are followed:
@@ -1064,7 +1066,7 @@ static apr_status_t buffer_output(request_rec *r,
 
     /* this will typically exit on the first test */
     for (f = r->output_filters; f != NULL; f = f->next)
-        if (strcasecmp("OLD_WRITE", f->frec->name) == 0)
+        if (ap_old_write_func == f->frec)
             break;
     if (f == NULL) {
         /* our filter hasn't been added yet */
index 6c00dd3dd1bb203ea303cb7ce41ea4744a2609c6..b26bbcc3af1a36ab98929d3ab52780a60e531574 100644 (file)
@@ -91,7 +91,7 @@ static apr_status_t filter_cleanup(void *ctx)
     return APR_SUCCESS;
 }
 
-static void register_filter(const char *name,
+static ap_filter_rec_t *register_filter(const char *name,
                             ap_filter_func filter_func,
                             ap_filter_type ftype,
                             apr_hash_t **reg_filter_set)
@@ -111,24 +111,25 @@ static void register_filter(const char *name,
 
     apr_pool_cleanup_register(FILTER_POOL, NULL, filter_cleanup, 
                               apr_pool_cleanup_null);
+    return frec;
 }
 
-AP_DECLARE(void) ap_register_input_filter(const char *name,
+AP_DECLARE(ap_filter_rec_t *) ap_register_input_filter(const char *name,
                                           ap_in_filter_func filter_func,
                                           ap_filter_type ftype)
 {
     ap_filter_func f;
     f.in_func = filter_func;
-    register_filter(name, f, ftype, &registered_input_filters);
+    return register_filter(name, f, ftype, &registered_input_filters);
 }                                                                    
 
-AP_DECLARE(void) ap_register_output_filter(const char *name,
+AP_DECLARE(ap_filter_rec_t *) ap_register_output_filter(const char *name,
                                            ap_out_filter_func filter_func,
                                            ap_filter_type ftype)
 {
     ap_filter_func f;
     f.out_func = filter_func;
-    register_filter(name, f, ftype, &registered_output_filters);
+    return register_filter(name, f, ftype, &registered_output_filters);
 }
 
 static ap_filter_t *add_any_filter(const char *name, void *ctx,