Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/indent indent: initialize 'ps' via code



details:   https://anonhg.NetBSD.org/src/rev/022dea02756b
branches:  trunk
changeset: 1024601:022dea02756b
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Oct 29 19:31:24 2021 +0000

description:
indent: initialize 'ps' via code

This saves 3 kB of binary size since the parser state is rather large
and only very few members are initialized to non-zero values.

No functional change.

diffstat:

 usr.bin/indent/indent.c |  14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diffs (42 lines):

diff -r 233a9040ef9f -r 022dea02756b usr.bin/indent/indent.c
--- a/usr.bin/indent/indent.c   Fri Oct 29 19:27:06 2021 +0000
+++ b/usr.bin/indent/indent.c   Fri Oct 29 19:31:24 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: indent.c,v 1.174 2021/10/29 19:22:55 rillig Exp $      */
+/*     $NetBSD: indent.c,v 1.175 2021/10/29 19:31:24 rillig Exp $      */
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.174 2021/10/29 19:22:55 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.175 2021/10/29 19:31:24 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -85,11 +85,7 @@
     .use_tabs = true,
 };
 
-struct parser_state ps = {
-    .s_sym[0] = psym_stmt,
-    .prev_token = lsym_semicolon,
-    .prev_newline = true,
-};
+struct parser_state ps;
 
 struct buffer lab;
 struct buffer code;
@@ -469,6 +465,10 @@
     buf_init(&lab);
     buf_init(&code);
 
+    ps.s_sym[0] = psym_stmt;
+    ps.prev_token = lsym_semicolon;
+    ps.prev_newline = true;
+
     const char *suffix = getenv("SIMPLE_BACKUP_SUFFIX");
     if (suffix != NULL)
        backup_suffix = suffix;



Home | Main Index | Thread Index | Old Index