]> granicus.if.org Git - apache/commitdiff
Make ap_rputs an inline function, as it is mostly used with string constants
authorStefan Fritsch <sf@apache.org>
Sat, 4 Jun 2011 18:50:55 +0000 (18:50 +0000)
committerStefan Fritsch <sf@apache.org>
Sat, 4 Jun 2011 18:50:55 +0000 (18:50 +0000)
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

include/ap_mmn.h
include/http_protocol.h
server/protocol.c

index c1343e1b635d838c0785c89dba0f542d0aa36691..a3afd13f7b80c4fec91f40b560ee28106e84a32f 100644 (file)
  * 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
index 61d33a3949bc8baed582bbc1466574acd63ea59a..996e606ef86e4e704b03fbc5797ba5d8308ed0d8 100644 (file)
@@ -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
index 624500830793e03bccda6ec1f9734dec167c4f65..7a9b5497e508e4c47c30d0736a4da8fb3fc184c9 100644 (file)
@@ -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)