You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ja...@apache.org on 2015/06/02 07:40:58 UTC
svn commit: r1683044 - /httpd/httpd/trunk/server/core.c
Author: jailletc36
Date: Tue Jun 2 05:40:57 2015
New Revision: 1683044
URL: http://svn.apache.org/r1683044
Log:
Skip a few bytes before calling 'strchr' if we know that they can't match.
s/apr_pstrndup/apr_pstrmemdup/ when applicable.
Fix a comment typo.
Modified:
httpd/httpd/trunk/server/core.c
Modified: httpd/httpd/trunk/server/core.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/core.c?rev=1683044&r1=1683043&r2=1683044&view=diff
==============================================================================
--- httpd/httpd/trunk/server/core.c (original)
+++ httpd/httpd/trunk/server/core.c Tue Jun 2 05:40:57 2015
@@ -1263,8 +1263,8 @@ AP_DECLARE(const char *) ap_resolve_env(
}
if (*s == '$') {
- if (s[1] == '{' && (e = ap_strchr_c(s, '}'))) {
- char *name = apr_pstrndup(p, s+2, e-s-2);
+ if (s[1] == '{' && (e = ap_strchr_c(s+2, '}'))) {
+ char *name = apr_pstrmemdup(p, s+2, e-s-2);
word = NULL;
if (server_config_defined_vars)
word = apr_table_get(server_config_defined_vars, name);
@@ -2147,7 +2147,7 @@ AP_CORE_DECLARE_NONSTD(const char *) ap_
return unclosed_directive(cmd);
}
- limited_methods = apr_pstrndup(cmd->temp_pool, arg, endp - arg);
+ limited_methods = apr_pstrmemdup(cmd->temp_pool, arg, endp - arg);
if (!limited_methods[0]) {
return missing_container_arg(cmd);
@@ -2164,7 +2164,7 @@ AP_CORE_DECLARE_NONSTD(const char *) ap_
return "TRACE cannot be controlled by <Limit>, see TraceEnable";
}
else if (methnum == M_INVALID) {
- /* method has not been registered yet, but resorce restriction
+ /* method has not been registered yet, but resource restriction
* is always checked before method handling, so register it.
*/
methnum = ap_method_register(cmd->pool,
Re: svn commit: r1683044 - /httpd/httpd/trunk/server/core.c
Posted by William A Rowe Jr <wr...@rowe-clan.net>.
On Thu, Jun 4, 2015 at 1:23 PM, Marion & Christophe JAILLET <
christophe.jaillet@wanadoo.fr> wrote:
>
> I agree that the wording of the Changelog could be more meaningful.
> Apparently these functions are only used during conf parsing. So, I propose
> to turn is into:
> "Small speed optimization when parsing <Limit, <LimitExcept and
> environment variables"
>
Yup, I agree.
Re: svn commit: r1683044 - /httpd/httpd/trunk/server/core.c
Posted by Marion & Christophe JAILLET <ch...@wanadoo.fr>.
Hi,
Skip a few bytes before calling 'strchr' if we know that they can't match.
=========================================================================
in 'ap_resolve_env', at line 1265 we have:
if (*s == '$') {
if (s[1] == '{' && (e = ap_strchr_c(s, '}'))) {
So, we looking for an ending '}', we alreay know that the 2 first
caracters are '$' and '{'
No need to scan them again. They can't match a '}'
So, I proposed to start the scan after these 2 bytes (i.e.
ap_strchr_c(s+2, '}')
s/apr_pstrndup/apr_pstrmemdup/ when applicable.
==============================================
#1) The line after, we apr_pstrndup what was within the '${' and '}'.
We know that (e-s-2) is shorter or equals to the length of '*s'.
So, pstrndup can be replaced by apr_pstrmemdup in order to avoid a
useless call to strlen.
#2) in 'ap_limit_section' line 2139 we have:
const char *endp = ap_strrchr_c(arg, '>');
Then we check if the '>' has been found at line 2146.
So, we know that (endp - arg) is shorter or equals to the length of
'arg' and that pstrndup can be replaced by apr_pstrmemdup in order to
avoid a useless call to strlen.
Fix a comment typo.
==================
resorce --> resource
I agree that the wording of the Changelog could be more meaningful.
Apparently these functions are only used during conf parsing. So, I
propose to turn is into:
"Small speed optimization when parsing <Limit, <LimitExcept and
environment variables"
Regards,
CJ
Le 03/06/2015 09:05, William A Rowe Jr a écrit :
>
> I tried to reconcile your patch with your svn log entry and I failed.
> Could you either correct or explain further?
>
> TIA,
>
> Bill
>
> On Jun 2, 2015 12:40 AM, <jailletc36@apache.org
> <ma...@apache.org>> wrote:
>
> Author: jailletc36
> Date: Tue Jun 2 05:40:57 2015
> New Revision: 1683044
>
> URL: http://svn.apache.org/r1683044
> Log:
> Skip a few bytes before calling 'strchr' if we know that they
> can't match.
> s/apr_pstrndup/apr_pstrmemdup/ when applicable.
> Fix a comment typo.
>
> Modified:
> httpd/httpd/trunk/server/core.c
>
> Modified: httpd/httpd/trunk/server/core.c
> URL:
> http://svn.apache.org/viewvc/httpd/httpd/trunk/server/core.c?rev=1683044&r1=1683043&r2=1683044&view=diff
> ==============================================================================
> --- httpd/httpd/trunk/server/core.c (original)
> +++ httpd/httpd/trunk/server/core.c Tue Jun 2 05:40:57 2015
> @@ -1263,8 +1263,8 @@ AP_DECLARE(const char *) ap_resolve_env(
> }
>
> if (*s == '$') {
> - if (s[1] == '{' && (e = ap_strchr_c(s, '}'))) {
> - char *name = apr_pstrndup(p, s+2, e-s-2);
> + if (s[1] == '{' && (e = ap_strchr_c(s+2, '}'))) {
> + char *name = apr_pstrmemdup(p, s+2, e-s-2);
> word = NULL;
> if (server_config_defined_vars)
> word =
> apr_table_get(server_config_defined_vars, name);
> @@ -2147,7 +2147,7 @@ AP_CORE_DECLARE_NONSTD(const char *) ap_
> return unclosed_directive(cmd);
> }
>
> - limited_methods = apr_pstrndup(cmd->temp_pool, arg, endp - arg);
> + limited_methods = apr_pstrmemdup(cmd->temp_pool, arg, endp -
> arg);
>
> if (!limited_methods[0]) {
> return missing_container_arg(cmd);
> @@ -2164,7 +2164,7 @@ AP_CORE_DECLARE_NONSTD(const char *) ap_
> return "TRACE cannot be controlled by <Limit>, see
> TraceEnable";
> }
> else if (methnum == M_INVALID) {
> - /* method has not been registered yet, but resorce
> restriction
> + /* method has not been registered yet, but resource
> restriction
> * is always checked before method handling, so
> register it.
> */
> methnum = ap_method_register(cmd->pool,
>
>
Re: svn commit: r1683044 - /httpd/httpd/trunk/server/core.c
Posted by William A Rowe Jr <wr...@rowe-clan.net>.
I tried to reconcile your patch with your svn log entry and I failed.
Could you either correct or explain further?
TIA,
Bill
On Jun 2, 2015 12:40 AM, <ja...@apache.org> wrote:
> Author: jailletc36
> Date: Tue Jun 2 05:40:57 2015
> New Revision: 1683044
>
> URL: http://svn.apache.org/r1683044
> Log:
> Skip a few bytes before calling 'strchr' if we know that they can't match.
> s/apr_pstrndup/apr_pstrmemdup/ when applicable.
> Fix a comment typo.
>
> Modified:
> httpd/httpd/trunk/server/core.c
>
> Modified: httpd/httpd/trunk/server/core.c
> URL:
> http://svn.apache.org/viewvc/httpd/httpd/trunk/server/core.c?rev=1683044&r1=1683043&r2=1683044&view=diff
>
> ==============================================================================
> --- httpd/httpd/trunk/server/core.c (original)
> +++ httpd/httpd/trunk/server/core.c Tue Jun 2 05:40:57 2015
> @@ -1263,8 +1263,8 @@ AP_DECLARE(const char *) ap_resolve_env(
> }
>
> if (*s == '$') {
> - if (s[1] == '{' && (e = ap_strchr_c(s, '}'))) {
> - char *name = apr_pstrndup(p, s+2, e-s-2);
> + if (s[1] == '{' && (e = ap_strchr_c(s+2, '}'))) {
> + char *name = apr_pstrmemdup(p, s+2, e-s-2);
> word = NULL;
> if (server_config_defined_vars)
> word = apr_table_get(server_config_defined_vars,
> name);
> @@ -2147,7 +2147,7 @@ AP_CORE_DECLARE_NONSTD(const char *) ap_
> return unclosed_directive(cmd);
> }
>
> - limited_methods = apr_pstrndup(cmd->temp_pool, arg, endp - arg);
> + limited_methods = apr_pstrmemdup(cmd->temp_pool, arg, endp - arg);
>
> if (!limited_methods[0]) {
> return missing_container_arg(cmd);
> @@ -2164,7 +2164,7 @@ AP_CORE_DECLARE_NONSTD(const char *) ap_
> return "TRACE cannot be controlled by <Limit>, see
> TraceEnable";
> }
> else if (methnum == M_INVALID) {
> - /* method has not been registered yet, but resorce restriction
> + /* method has not been registered yet, but resource
> restriction
> * is always checked before method handling, so register it.
> */
> methnum = ap_method_register(cmd->pool,
>
>
>