Commit 9b88c3c8 authored by Stefan Fritsch's avatar Stefan Fritsch
Browse files

Make ap_rputs an inline function, as it is mostly used with string constants

and this allows the compiler to optimize the strlen() call away.

Submitted by: Christophe Jaillet <christophe jaillet wanadoo fr>


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1131465 13f79535-47bb-0310-9956-ffa450edef68
parent 8670ce7c
Loading
Loading
Loading
Loading
+3 −2
Changes for include/ap_mmn.h: 3 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -325,14 +325,15 @@
 * 20110329.5 (2.3.13-dev) Add ap_regexec_len()
 * 20110329.6 (2.3.13-dev) Add AP_EXPR_FLAGS_RESTRICTED, ap_expr_eval_ctx_t->data,
 *                         ap_expr_exec_ctx()
 * 20110604.0 (2.3.13-dev) Make ap_rputs() inline
 */

#define MODULE_MAGIC_COOKIE 0x41503234UL /* "AP24" */

#ifndef MODULE_MAGIC_NUMBER_MAJOR
#define MODULE_MAGIC_NUMBER_MAJOR 20110329
#define MODULE_MAGIC_NUMBER_MAJOR 20110604
#endif
#define MODULE_MAGIC_NUMBER_MINOR 6                    /* 0...n */
#define MODULE_MAGIC_NUMBER_MINOR 0                    /* 0...n */

/**
 * Determine if the server's current MODULE_MAGIC_NUMBER is at least a
+11 −7
Changes for include/http_protocol.h: 11 added lines, 7 removed lines.
Original line number Diff line number Diff line
@@ -319,21 +319,25 @@ AP_DECLARE(void) ap_set_content_type(request_rec *r, const char *ct);
AP_DECLARE(int) ap_rputc(int c, request_rec *r);

/**
 * Output a string for the current request
 * @param str The string to output
 * Write a buffer for the current request
 * @param buf The buffer to write
 * @param nbyte The number of bytes to send from the buffer
 * @param r The current request
 * @return The number of bytes sent
 */
AP_DECLARE(int) ap_rputs(const char *str, request_rec *r);
AP_DECLARE(int) ap_rwrite(const void *buf, int nbyte, request_rec *r);

/**
 * Write a buffer for the current request
 * @param buf The buffer to write
 * @param nbyte The number of bytes to send from the buffer
 * Output a string for the current request
 * @param str The string to output
 * @param r The current request
 * @return The number of bytes sent
 * @note ap_rputs may be implemented as macro or inline function
 */
AP_DECLARE(int) ap_rwrite(const void *buf, int nbyte, request_rec *r);
static inline int ap_rputs(const char *str, request_rec *r)
{
    return ap_rwrite(str, strlen(str), r);
}

/**
 * Write an unspecified number of strings to the request
+0 −13
Changes for server/protocol.c: 0 added lines, 13 removed lines.
Original line number Diff line number Diff line
@@ -1509,19 +1509,6 @@ AP_DECLARE(int) ap_rputc(int c, request_rec *r)
    return c;
}

AP_DECLARE(int) ap_rputs(const char *str, request_rec *r)
{
    apr_size_t len;

    if (r->connection->aborted)
        return -1;

    if (buffer_output(r, str, len = strlen(str)) != APR_SUCCESS)
        return -1;

    return len;
}

AP_DECLARE(int) ap_rwrite(const void *buf, int nbyte, request_rec *r)
{
    if (r->connection->aborted)