git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Make struct commands[] const to save a couple bytes

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Nov 3, 2007, 11:13 UTC
Message-ID
<20071103111324.GA30441@laptop>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 .data got reduced by 960 bytes. Not much, but anyway ;)
 git.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/git.c b/git.c
index 4e10581..d0a2042 100644
--- a/git.c
+++ b/git.c
@@ -238,7 +238,7 @@ struct cmd_struct {
 	int option;
 };
 
-static int run_command(struct cmd_struct *p, int argc, const char **argv)
+static int run_command(const struct cmd_struct *p, int argc, const char **argv)
 {
 	int status;
 	struct stat st;
@@ -283,7 +283,7 @@ static int run_command(struct cmd_struct *p, int argc, const char **argv)
 static void handle_internal_command(int argc, const char **argv)
 {
 	const char *cmd = argv[0];
-	static struct cmd_struct commands[] = {
+	static const struct cmd_struct commands[] = {
 		{ "add", cmd_add, RUN_SETUP | NEED_WORK_TREE },
 		{ "annotate", cmd_annotate, RUN_SETUP },
 		{ "apply", cmd_apply },
@@ -375,7 +375,7 @@ static void handle_internal_command(int argc, const char **argv)
 	}
 
 	for (i = 0; i < ARRAY_SIZE(commands); i++) {
-		struct cmd_struct *p = commands+i;
+		const struct cmd_struct *p = commands+i;
 		if (strcmp(p->cmd, cmd))
 			continue;
 		exit(run_command(p, argc, argv));
-- 
1.5.3.rc4.3.gab089
Message 1 of 1 in “Make struct commands[] const to save a couple bytes”
  1. Make struct commands[] const to save a couple bytesNguyễn Thái Ngọc Duy, Nov 3, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.