gawk-diffs
[Top][All Lists]
Advanced

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

[gawk-diffs] [SCM] gawk branch, feature/fixtype, updated. gawk-4.1.0-189


From: Andrew J. Schorr
Subject: [gawk-diffs] [SCM] gawk branch, feature/fixtype, updated. gawk-4.1.0-1891-g166a253
Date: Wed, 6 Jul 2016 01:56:06 +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, feature/fixtype has been updated
       via  166a253ca87240fe7ec463223af0b25a3e0f3d8a (commit)
      from  f421a5fbef014040712a7c89e8863c7196f6ab93 (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=166a253ca87240fe7ec463223af0b25a3e0f3d8a

commit 166a253ca87240fe7ec463223af0b25a3e0f3d8a
Author: Andrew J. Schorr <address@hidden>
Date:   Tue Jul 5 21:55:46 2016 -0400

    When rebuilding $0, do not bother to copy malloc'ed nodes.

diff --git a/ChangeLog b/ChangeLog
index e0acc21..8ecec42 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2016-07-05         Andrew J. Schorr     <address@hidden>
 
+       * field.c (rebuild_record): Do not bother to create new field nodes
+       to replace malloc'ed nodes when rebuilding $0.
+
+2016-07-05         Andrew J. Schorr     <address@hidden>
+
        * awk.h (FIELD): Remove unnecessary flag.
        (MALLOC): Move definition to join the others, and improve the comment.
        * array.c (value_info): Replace FIELD test with MALLOC test.
diff --git a/field.c b/field.c
index 823e7a7..308f33c 100644
--- a/field.c
+++ b/field.c
@@ -194,41 +194,30 @@ rebuild_record()
         */
        for (cops = ops, i = 1; i <= NF; i++) {
                NODE *r = fields_arr[i];
-               if (r->stlen > 0) {
+               /*
+                * I see no reason to copy malloc'ed fields to point into
+                * the new $0 buffer, but that's how previous versions did it.
+                * It seems faster to leave the malloc'ed fields in place.
+                */
+               if (r->stlen > 0 && (r->flags & MALLOC) == 0) {
                        NODE *n;
                        getnode(n);
 
-                       if ((r->flags & MALLOC) != 0) {
-                               *n = *Null_field;
-                               n->stlen = r->stlen;
-                               if ((r->flags & (NUMCUR|NUMBER)) != 0) {
-                                       n->flags |= (r->flags & 
(MPFN|MPZN|NUMCUR|NUMBER));
-#ifdef HAVE_MPFR
-                                       if (is_mpg_float(r)) {
-                                               mpfr_init(n->mpg_numbr);
-                                               mpfr_set(n->mpg_numbr, 
r->mpg_numbr, ROUND_MODE);
-                                       } else if (is_mpg_integer(r)) {
-                                               mpz_init(n->mpg_i);
-                                               mpz_set(n->mpg_i, r->mpg_i);
-                                       } else
-#endif
-                                       n->numbr = r->numbr;
-                               }
-                       } else {
-                               *n = *r;
-                               if (r->valref > 1) {
-                                       /*
-                                        * XXX This probably should never
-                                        * happen, but we can't leave r with
-                                        * stptr pointing into the old $0
-                                        * buffer. Perhaps we should issue a
-                                        * warning message about memory
-                                        * corruption...
-                                        */
-                                       emalloc(r->stptr, char *, r->stlen + 1, 
"rebuild_record");
-                                       memcpy(r->stptr, cops, r->stlen);
-                                       r->stptr[r->stlen] = '\0';
-                               }
+                       *n = *r;
+                       if (r->valref > 1) {
+                               /*
+                                * I don't think this should happen, since it
+                                * was not considered by previous versions of
+                                * this function. But it seems clear to me that
+                                * we can't leave r's stptr pointing into the
+                                * old $0 buffer that we are about to unref.
+                                * It's not obvious to me that valref must be
+                                * 1 in all cases, so it seems wise to suppport
+                                * this corner case.
+                                */
+                               emalloc(r->stptr, char *, r->stlen + 1, 
"rebuild_record");
+                               memcpy(r->stptr, cops, r->stlen);
+                               r->stptr[r->stlen] = '\0';
                        }
 
                        n->stptr = cops;

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

Summary of changes:
 ChangeLog |    5 +++++
 field.c   |   53 +++++++++++++++++++++--------------------------------
 2 files changed, 26 insertions(+), 32 deletions(-)


hooks/post-receive
-- 
gawk



reply via email to

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