From: Stefan Fritsch Date: Sat, 4 Jun 2011 18:50:55 +0000 (+0000) Subject: Make ap_rputs an inline function, as it is mostly used with string constants X-Git-Tag: 2.3.13~82 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cdb37c5e4d684dd22c702a1d8ae65ab875603d40;p=thirdparty%2Fapache%2Fhttpd.git 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 git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1131465 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/include/ap_mmn.h b/include/ap_mmn.h index c1343e1b635..a3afd13f7b8 100644 --- a/include/ap_mmn.h +++ b/include/ap_mmn.h @@ -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 diff --git a/include/http_protocol.h b/include/http_protocol.h index 61d33a3949b..996e606ef86 100644 --- a/include/http_protocol.h +++ b/include/http_protocol.h @@ -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 diff --git a/server/protocol.c b/server/protocol.c index 62450083079..7a9b5497e50 100644 --- a/server/protocol.c +++ b/server/protocol.c @@ -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)