diff options
author | Andrew J. Schorr <aschorr@telemetry-investments.com> | 2016-07-06 18:11:10 -0400 |
---|---|---|
committer | Andrew J. Schorr <aschorr@telemetry-investments.com> | 2016-07-06 18:11:10 -0400 |
commit | f8424b236fabb881cc977b9e8e2e7c8debf56da0 (patch) | |
tree | ffbcb123b366ff6948c5d51fe784f22bbdc9929b | |
parent | 5de217ef7d347b8afa6f6f1fbd20cb84a20ae187 (diff) | |
download | egawk-f8424b236fabb881cc977b9e8e2e7c8debf56da0.tar.gz egawk-f8424b236fabb881cc977b9e8e2e7c8debf56da0.tar.bz2 egawk-f8424b236fabb881cc977b9e8e2e7c8debf56da0.zip |
Now that all fields are NUL-terminated, we can eliminate $n copying in the interpreter.
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | interpret.h | 8 |
2 files changed, 12 insertions, 6 deletions
@@ -1,5 +1,15 @@ 2016-07-06 Andrew J. Schorr <aschorr@telemetry-investments.com> + * interpret.h (Op_field_spec): Now that all $n field values are + NUL-terminated, there is no reason to call dupnode for $n where n > 0. + This saves malloc and copying overhead, thereby more than offsetting the + performance hit of the additional copying and NUL-termination in the + last patch to field.c. It also eliminates repeated parsing in cases + where $n, for n > 1, was accessed more than once in a numeric context, + so the new approach should be a performance win. + +2016-07-06 Andrew J. Schorr <aschorr@telemetry-investments.com> + Make sure that all field values, and therefore all strings inside gawk, are terminated with a '\0' character! * field.c (databuf): New static struct to hold info about our buffer to diff --git a/interpret.h b/interpret.h index bbddd5a7..106367f7 100644 --- a/interpret.h +++ b/interpret.h @@ -363,12 +363,8 @@ uninitialized_scalar: lhs = r_get_field(t1, (Func_ptr *) 0, true); decr_sp(); DEREF(t1); - /* only for $0, up ref count */ - if (*lhs == fields_arr[0]) { - r = *lhs; - UPREF(r); - } else - r = dupnode(*lhs); + r = *lhs; + UPREF(r); PUSH(r); break; |