This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "GNU M4 source repository".
http://git.sv.gnu.org/gitweb/?p=m4.git;a=commitdiff;h=f7f652750c6d3f38d98a39156ad21e96a6c1dfa5 The branch, branch-1.6 has been updated via f7f652750c6d3f38d98a39156ad21e96a6c1dfa5 (commit) from 10b0347d04e2d00fddfce01d0321d3e75aaf6520 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit f7f652750c6d3f38d98a39156ad21e96a6c1dfa5 Author: Eric Blake <[EMAIL PROTECTED]> Date: Wed Jun 18 17:09:48 2008 -0600 Revert speed regression from previous patch. * src/builtin.c (shipout_int, m4_eval): Avoid obstack_printf in hot paths. * src/input.c (MATCH): Use fewer conditionals, and factor adjustment of S... (match_input): ...here for smaller code size. (input_init, set_quotes, set_comment): Supply trailing NUL to delimiters, to meet contract of faster MATCH. Signed-off-by: Eric Blake <[EMAIL PROTECTED]> ----------------------------------------------------------------------- Summary of changes: ChangeLog | 11 +++++++++- src/builtin.c | 15 ++++++++++--- src/input.c | 61 ++++++++++++++++++++++++++++++++------------------------ 3 files changed, 56 insertions(+), 31 deletions(-) diff --git a/ChangeLog b/ChangeLog index 60a5a9e..794d6d7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,12 +1,21 @@ 2008-06-18 Eric Blake <[EMAIL PROTECTED]> + Revert speed regression from previous patch. + * src/builtin.c (shipout_int, m4_eval): Avoid obstack_printf in + hot paths. + * src/input.c (MATCH): Use fewer conditionals, and factor + adjustment of S... + (match_input): ...here for smaller code size. + (input_init, set_quotes, set_comment): Supply trailing NUL to + delimiters, to meet contract of faster MATCH. + Stage 25: Handle embedded NUL in changequote and changecom. Track quote and comment delimiters by length, to allow embedded NUL. Convert macro tracing and other locations to use obstack_printf rather than hand-rolled equivalents. Ensure that embedded NUL in trace output does not truncate the trace string. Memory impact: none. - Speed impact: none noticed. + Speed impact: noticeable penalty, from obstack_printf overhead. * m4/gnulib-cache.m4: Import obstack-printf-posix module. * src/m4.h (ntoa): Remove declaration. (DEBUG_PRINT1, DEBUG_PRINT3, MESSAGE, DEBUG_MESSAGE1) diff --git a/src/builtin.c b/src/builtin.c index 6b107ae..d64b567 100644 --- a/src/builtin.c +++ b/src/builtin.c @@ -629,7 +629,10 @@ ntoa (int32_t value, int radix) static void shipout_int (struct obstack *obs, int val) { - obstack_printf (obs, "%d", val); + const char *s; + + s = ntoa ((int32_t) val, 10); + obstack_grow (obs, s, strlen (s)); } @@ -1227,9 +1230,13 @@ m4_eval (struct obstack *obs, int argc, macro_arguments *argv) s++; } len = strlen (s); - if (min < len) - min = len; - obstack_printf (obs, "%.*d%s", min - len, 0, s); + if (len < min) + { + min -= len; + obstack_blank (obs, min); + memset (obstack_next_free (obs) - min, '0', min); + } + obstack_grow (obs, s, len); } static void diff --git a/src/input.c b/src/input.c index 589fbb1..18271cd 100644 --- a/src/input.c +++ b/src/input.c @@ -1197,11 +1197,12 @@ init_argv_token (struct obstack *obs, token_data *td) /*------------------------------------------------------------------. -| This function is for matching a string against a prefix of the | -| input stream. If the string S of length SLEN matches the input | -| and CONSUME is true, the input is discarded; otherwise any | -| characters read are pushed back again. The function is used only | -| when multicharacter quotes or comment delimiters are used. | +| If the string S of length SLEN matches the next characters of the | +| input stream, return true. If CONSUME, the first character has | +| already been matched. If a match is found and CONSUME is true, | +| the input is discarded; otherwise any characters read are pushed | +| back again. The function is used only when multicharacter quotes | +| or comment delimiters are used. | `------------------------------------------------------------------*/ static bool @@ -1212,6 +1213,11 @@ match_input (const char *s, size_t slen, bool consume) const char *t; bool result = false; + if (consume) + { + s++; + slen--; + } assert (slen); ch = peek_input (false); if (ch != to_uchar (*s)) @@ -1245,21 +1251,22 @@ match_input (const char *s, size_t slen, bool consume) return result; } -/*---------------------------------------------------------------. -| The macro MATCH() is used to match a string S of length SLEN | -| against the input. The first character is handled inline, for | -| speed. Hopefully, this will not hurt efficiency too much when | -| single character quotes and comment delimiters are used. If | -| CONSUME, then CH is the result of next_char, and a successful | -| match will discard the matched string. Otherwise, CH is the | -| result of peek_input, and the input stream is effectively | -| unchanged. | -`---------------------------------------------------------------*/ +/*--------------------------------------------------------------------. +| The macro MATCH() is used to match a string S of length SLEN | +| against the input. The first character is handled inline for | +| speed, and S[SLEN] must be safe to dereference (it is faster to do | +| character comparison prior to length checks). This improves | +| efficiency for the common case of single character quotes and | +| comment delimiters, while being safe for disabled delimiters as | +| well as longer delimiters. If CONSUME, then CH is the result of | +| next_char, and a successful match will discard the matched string. | +| Otherwise, CH is the result of peek_input, and the input stream is | +| effectively unchanged. | +`--------------------------------------------------------------------*/ #define MATCH(ch, s, slen, consume) \ - ((slen) && to_uchar ((s)[0]) == (ch) \ - && ((slen) == 1 \ - || (match_input ((s) + (consume), (slen) - (consume), consume)))) + (to_uchar ((s)[0]) == (ch) \ + && ((slen) >> 1 ? match_input (s, slen, consume) : (slen))) /*----------------------------------------------------------. @@ -1291,13 +1298,13 @@ input_init (void) start_of_input_line = false; - curr_quote.str1 = xmemdup (DEF_LQUOTE, 1); + curr_quote.str1 = xmemdup0 (DEF_LQUOTE, 1); curr_quote.len1 = 1; - curr_quote.str2 = xmemdup (DEF_RQUOTE, 1); + curr_quote.str2 = xmemdup0 (DEF_RQUOTE, 1); curr_quote.len2 = 1; - curr_comm.str1 = xmemdup (DEF_BCOMM, 1); + curr_comm.str1 = xmemdup0 (DEF_BCOMM, 1); curr_comm.len1 = 1; - curr_comm.str2 = xmemdup (DEF_ECOMM, 1); + curr_comm.str2 = xmemdup0 (DEF_ECOMM, 1); curr_comm.len2 = 1; #ifdef ENABLE_CHANGEWORD @@ -1345,9 +1352,10 @@ set_quotes (const char *lq, size_t lq_len, const char *rq, size_t rq_len) free (curr_quote.str1); free (curr_quote.str2); - curr_quote.str1 = xmemdup (lq, lq_len); + /* The use of xmemdup0 is essential for MATCH() to work. */ + curr_quote.str1 = xmemdup0 (lq, lq_len); curr_quote.len1 = lq_len; - curr_quote.str2 = xmemdup (rq, rq_len); + curr_quote.str2 = xmemdup0 (rq, rq_len); curr_quote.len2 = rq_len; set_quote_age (); } @@ -1387,9 +1395,10 @@ set_comment (const char *bc, size_t bc_len, const char *ec, size_t ec_len) free (curr_comm.str1); free (curr_comm.str2); - curr_comm.str1 = xmemdup (bc, bc_len); + /* The use of xmemdup0 is essential for MATCH() to work. */ + curr_comm.str1 = xmemdup0 (bc, bc_len); curr_comm.len1 = bc_len; - curr_comm.str2 = xmemdup (ec, ec_len); + curr_comm.str2 = xmemdup0 (ec, ec_len); curr_comm.len2 = ec_len; set_quote_age (); } hooks/post-receive -- GNU M4 source repository
