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
* @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.
* 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);
/**
* ::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);
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 = {
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:
/* 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 */
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)
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,