From cac07fa8d9ffb4a1198dc1a90dfc0a5fc26af606 Mon Sep 17 00:00:00 2001 From: Ryan Bloom Date: Tue, 11 Sep 2001 18:38:21 +0000 Subject: [PATCH] A very small optimization to the OLD_WRITE logic. This just makes us store 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 | 5 +++++ include/util_filter.h | 4 ++-- server/core.c | 4 ++-- server/protocol.c | 4 +++- server/util_filter.c | 11 ++++++----- 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/include/http_protocol.h b/include/http_protocol.h index d3065f672c..b6073da092 100644 --- a/include/http_protocol.h +++ b/include/http_protocol.h @@ -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. diff --git a/include/util_filter.h b/include/util_filter.h index 7ba39b4915..9dc061fb74 100644 --- a/include/util_filter.h +++ b/include/util_filter.h @@ -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); diff --git a/server/core.c b/server/core.c index 0663e6b3a8..6639889645 100644 --- a/server/core.c +++ b/server/core.c @@ -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 = { diff --git a/server/protocol.c b/server/protocol.c index 80fa2ee191..336aec5825 100644 --- a/server/protocol.c +++ b/server/protocol.c @@ -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 */ diff --git a/server/util_filter.c b/server/util_filter.c index 6c00dd3dd1..b26bbcc3af 100644 --- a/server/util_filter.c +++ b/server/util_filter.c @@ -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, ®istered_input_filters); + return register_filter(name, f, ftype, ®istered_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, ®istered_output_filters); + return register_filter(name, f, ftype, ®istered_output_filters); } static ap_filter_t *add_any_filter(const char *name, void *ctx, -- 2.50.1