[git commit] awk: g_buf[] does not need a separate allocation
Denys Vlasenko
vda.linux at googlemail.com
Tue Jun 29 00:43:02 UTC 2021
commit: https://git.busybox.net/busybox/commit/?id=cb6061a4e9860bf3d529109b34103ce3bde6d735
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master
function old new delta
exec_builtin 1400 1414 +14
evaluate 3132 3141 +9
getvar_s 121 125 +4
awk_main 902 886 -16
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/1 up/down: 27/-16) Total: 11 bytes
Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
editors/awk.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/editors/awk.c b/editors/awk.c
index 08ff02adb..7e4f0d142 100644
--- a/editors/awk.c
+++ b/editors/awk.c
@@ -535,7 +535,6 @@ struct globals {
var *Fields;
nvblock *g_cb;
char *g_pos;
- char *g_buf;
smallint icase;
smallint exiting;
smallint nextrec;
@@ -571,6 +570,8 @@ struct globals2 {
/* biggest and least used members go last */
tsplitter fsplitter, rsplitter;
+
+ char g_buf[MAXVARFMT + 1];
};
#define G1 (ptr_to_globals[-1])
#define G (*(struct globals2 *)ptr_to_globals)
@@ -598,7 +599,6 @@ struct globals2 {
#define Fields (G1.Fields )
#define g_cb (G1.g_cb )
#define g_pos (G1.g_pos )
-#define g_buf (G1.g_buf )
#define icase (G1.icase )
#define exiting (G1.exiting )
#define nextrec (G1.nextrec )
@@ -612,6 +612,7 @@ struct globals2 {
#define intvar (G.intvar )
#define fsplitter (G.fsplitter )
#define rsplitter (G.rsplitter )
+#define g_buf (G.g_buf )
#define INIT_G() do { \
SET_PTR_TO_GLOBALS((char*)xzalloc(sizeof(G1)+sizeof(G)) + sizeof(G1)); \
t_tclass = TS_OPTERM; \
@@ -3353,9 +3354,6 @@ int awk_main(int argc UNUSED_PARAM, char **argv)
if (ENABLE_LOCALE_SUPPORT)
setlocale(LC_NUMERIC, "C");
- /* allocate global buffer */
- g_buf = xmalloc(MAXVARFMT + 1);
-
vhash = hash_init();
ahash = hash_init();
fdhash = hash_init();
More information about the busybox-cvs
mailing list