gawk-diffs
[Top][All Lists]
Advanced

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

[gawk-diffs] [SCM] gawk branch, gawk-4.1-stable, updated. gawk-4.1.0-893


From: Andrew J. Schorr
Subject: [gawk-diffs] [SCM] gawk branch, gawk-4.1-stable, updated. gawk-4.1.0-893-g41412a8
Date: Thu, 26 May 2016 16:13:53 +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, gawk-4.1-stable has been updated
       via  41412a86f2ca0baf908fe0b2e4bcc396f66989ae (commit)
      from  ec5169b2f883a72dbe7c4515198199674017940a (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=41412a86f2ca0baf908fe0b2e4bcc396f66989ae

commit 41412a86f2ca0baf908fe0b2e4bcc396f66989ae
Author: Andrew J. Schorr <address@hidden>
Date:   Thu May 26 12:13:02 2016 -0400

    Optimize API function argument retrieval to eliminate a duplicate call to 
get_argument.

diff --git a/ChangeLog b/ChangeLog
index e066765..8d408e1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2016-05-26         Andrew J. Schorr     <address@hidden>
+
+       * awk.h (get_actual_argument): Add an initial argument containing the
+       (NODE *) previously returned by get_argument. This allows us to
+       eliminate a call to get_argument from inside get_actual_argument.
+       (get_scalar_argument, get_array_argument): Change macro definition to
+       add an initial node argument to pass through to get_actual_argument.
+       * ext.c (get_actual_argument): Add initial (NODE *) argument to contain
+       the value previously returned by get_argument. This allows us to
+       avoid repeating the call to get_argument. We can also eliminate the
+       check for a NULL value, since the caller did that already.
+       * gawkapi.c (api_get_argument): Pass (NODE *) returned by get_argument
+       to get_array_argument and get_scalar_argument.
+       (api_set_argument): Pass (NODE *) returned by get_argument to
+       get_array_argument.
+
 2016-05-12         Arnold Robbins       <address@hidden>
 
        * str_array.c (str_lookup): Remove MAYBE_NUM from subscript flags.
diff --git a/awk.h b/awk.h
index 925a9d6..ecc87f1 100644
--- a/awk.h
+++ b/awk.h
@@ -1441,9 +1441,9 @@ extern void close_extensions(void);
 extern void make_old_builtin(const char *, NODE *(*)(int), int);
 extern awk_bool_t make_builtin(const awk_ext_func_t *);
 extern NODE *get_argument(int);
-extern NODE *get_actual_argument(int, bool, bool);
-#define get_scalar_argument(i, opt)  get_actual_argument((i), (opt), false)
-#define get_array_argument(i, opt)   get_actual_argument((i), (opt), true)
+extern NODE *get_actual_argument(NODE *, int, bool, bool);
+#define get_scalar_argument(n, i, opt)  get_actual_argument((n), (i), (opt), 
false)
+#define get_array_argument(n, i, opt)   get_actual_argument((n), (i), (opt), 
true)
 #endif
 /* field.c */
 extern void init_fields(void);
diff --git a/ext.c b/ext.c
index cf81367..c3e34b1 100644
--- a/ext.c
+++ b/ext.c
@@ -334,28 +334,14 @@ get_argument(int i)
  */
 
 NODE *
-get_actual_argument(int i, bool optional, bool want_array)
+get_actual_argument(NODE *t, int i, bool optional, bool want_array)
 {
-       NODE *t;
        char *fname;
-       int pcount;
        INSTRUCTION *pc;
        
        pc = TOP()->code_ptr;   /* Op_ext_builtin instruction */
        fname = (pc + 1)->func_name;
-       pcount = (pc + 1)->expr_count;
  
-       t = get_argument(i);
-       if (t == NULL) {
-               if (i >= pcount)                /* must be fatal */
-                       fatal(_("function `%s' defined to take no more than %d 
argument(s)"),
-                                       fname, pcount);
-               if (! optional)
-                       fatal(_("function `%s': missing argument #%d"),
-                                       fname, i + 1);
-               return NULL;
-       }
-
        if (t->type == Node_var_new) {
                if (want_array)
                        return force_array(t, false);
diff --git a/gawkapi.c b/gawkapi.c
index 3b49545..779506c 100644
--- a/gawkapi.c
+++ b/gawkapi.c
@@ -82,7 +82,7 @@ api_get_argument(awk_ext_id_t id, size_t count,
 
 array:
        /* get the array here */
-       arg = get_array_argument(count, false);
+       arg = get_array_argument(arg, count, false);
        if (arg == NULL)
                return awk_false;
 
@@ -90,7 +90,7 @@ array:
 
 scalar:
        /* at this point we have a real type that is not an array */
-       arg = get_scalar_argument(count, false);
+       arg = get_scalar_argument(arg, count, false);
        if (arg == NULL)
                return awk_false;
 
@@ -120,7 +120,7 @@ api_set_argument(awk_ext_id_t id,
            || arg->type != Node_var_new)
                return awk_false;
 
-       arg = get_array_argument(count, false);
+       arg = get_array_argument(arg, count, false);
        if (arg == NULL)
                return awk_false;
 

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

Summary of changes:
 ChangeLog |   16 ++++++++++++++++
 awk.h     |    6 +++---
 ext.c     |   16 +---------------
 gawkapi.c |    6 +++---
 4 files changed, 23 insertions(+), 21 deletions(-)


hooks/post-receive
-- 
gawk



reply via email to

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