gawk-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gawk-diffs] [SCM] gawk branch, master, updated. gawk-4.1.0-1990-g43a812


From: Arnold Robbins
Subject: [gawk-diffs] [SCM] gawk branch, master, updated. gawk-4.1.0-1990-g43a8120
Date: Wed, 12 Oct 2016 20:24:46 +0000 (UTC)

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 "gawk".

The branch, master has been updated
       via  43a8120a00068448c4ffa60db37bdb8e782df321 (commit)
      from  662a50264f770f5bd972bee0e1980b9cb08ff41d (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 -----------------------------------------------------------------
http://git.sv.gnu.org/cgit/gawk.git/commit/?id=43a8120a00068448c4ffa60db37bdb8e782df321

commit 43a8120a00068448c4ffa60db37bdb8e782df321
Author: Arnold D. Robbins <address@hidden>
Date:   Wed Oct 12 23:24:19 2016 +0300

    Optimization in storing numeric string values for profiling. Update NEWS.

diff --git a/ChangeLog b/ChangeLog
index eed758c..2c0090a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2016-10-12         Arnold D. Robbins     <address@hidden>
+
+       * awkgram.y (make_profile_number): Allocate an extra byte for the
+       string, so there's room for a minus if necessary. Store '\0'
+       in the right place.
+       (negate_num): Use memmove to shift the string up and then
+       insert a minus, instead of doing a fresh alloc + copy + free.
+
 2016-10-11         Arnold D. Robbins     <address@hidden>
 
        * awk.h (NUMCONSTSTR): New flag value.
diff --git a/NEWS b/NEWS
index 7163ecf..1d84496 100644
--- a/NEWS
+++ b/NEWS
@@ -79,6 +79,9 @@ Changes from 4.1.x to 4.2.0
 20. Gawk now uses fwrite_unlocked if it's available. The yields a 7% - 18%
     improvement in raw output speed (gawk '{ print }' on a large file).
 
+21. Pretty printing now uses the original text of constant numeric values for
+    pretty printing and profiling.
+
 Changes from 4.1.3 to 4.1.4
 ---------------------------
 
diff --git a/awkgram.c b/awkgram.c
index b7ad577..2b88d3f 100644
--- a/awkgram.c
+++ b/awkgram.c
@@ -4533,11 +4533,9 @@ negate_num(NODE *n)
        if ((n->flags & NUMCONSTSTR) != 0) {
                char *s;
 
-               emalloc(s, char *, n->stlen + 1 + 1, "negate_num");
+               s = n->stptr;
+               memmove(& s[1], & s[0], n->stlen + 1);
                s[0] = '-';
-               strcpy(& s[1], n->stptr);
-               free(n->stptr);
-               n->stptr = s;
                n->stlen++;
        }
 
@@ -8598,7 +8596,9 @@ make_profile_number(double d, const char *str, size_t len)
 {
        NODE *n = make_number(d);
        if (do_pretty_print) {
-               n->stptr = estrdup(str, len);
+               // extra byte in case need to add minus sign in negate_num
+               n->stptr = estrdup(str, len + 1);
+               n->stptr[len] = '\0';
                n->stlen = len;
                n->flags |= NUMCONSTSTR;
        }
diff --git a/awkgram.y b/awkgram.y
index c81e295..11fbd9d 100644
--- a/awkgram.y
+++ b/awkgram.y
@@ -2156,11 +2156,9 @@ negate_num(NODE *n)
        if ((n->flags & NUMCONSTSTR) != 0) {
                char *s;
 
-               emalloc(s, char *, n->stlen + 1 + 1, "negate_num");
+               s = n->stptr;
+               memmove(& s[1], & s[0], n->stlen + 1);
                s[0] = '-';
-               strcpy(& s[1], n->stptr);
-               free(n->stptr);
-               n->stptr = s;
                n->stlen++;
        }
 
@@ -6221,7 +6219,9 @@ make_profile_number(double d, const char *str, size_t len)
 {
        NODE *n = make_number(d);
        if (do_pretty_print) {
-               n->stptr = estrdup(str, len);
+               // extra byte in case need to add minus sign in negate_num
+               n->stptr = estrdup(str, len + 1);
+               n->stptr[len] = '\0';
                n->stlen = len;
                n->flags |= NUMCONSTSTR;
        }

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog |    8 ++++++++
 NEWS      |    3 +++
 awkgram.c |   10 +++++-----
 awkgram.y |   10 +++++-----
 4 files changed, 21 insertions(+), 10 deletions(-)


hooks/post-receive
-- 
gawk



reply via email to

[Prev in Thread] Current Thread [Next in Thread]