Commit 66359607 authored by Ryan Bloom's avatar Ryan Bloom
Browse files

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
parent 4f63710a
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -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.
+2 −2
Original line number Diff line number Diff line
@@ -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);

+2 −2
Original line number Diff line number Diff line
@@ -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 = {
+3 −1
Original line number Diff line number Diff line
@@ -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 */
+6 −5
Original line number Diff line number Diff line
@@ -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,