From c8141a8158c1690c048689358e637558f248c577 Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 24 Feb 2015 04:51:39 +0000 Subject: [PATCH] win32.c: reduce memory size * win32/win32.c (szInternalCmds): reduce memory size, from 506 on 32bit and 702 on 64bit to 490 bytes, and remove relocations. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49714 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- win32/win32.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/win32/win32.c b/win32/win32.c index b7d7e32935..48712f7b9c 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -865,7 +865,8 @@ FindFreeChildSlot(void) -e 'END{$cmds.sort.each{|n,f|puts " \"\\#{f.to_s(8)}\" #{n.dump} + 1,"}}' 98cmd ntcmd */ -static const char *const szInternalCmds[] = { +#define InternalCmdsMax 8 +static const char szInternalCmds[][InternalCmdsMax+2] = { "\2" "assoc", "\3" "break", "\3" "call", @@ -921,7 +922,7 @@ static const char *const szInternalCmds[] = { static int internal_match(const void *key, const void *elem) { - return strcmp(key, (*(const char *const *)elem) + 1); + return strncmp(key, ((const char *)elem) + 1, InternalCmdsMax); } /* License: Ruby's */ @@ -972,13 +973,13 @@ is_internal_cmd(const char *cmd, int nt) static int internal_cmd_match(const char *cmdname, int nt) { - char **nm; + char *nm; nm = bsearch(cmdname, szInternalCmds, sizeof(szInternalCmds) / sizeof(*szInternalCmds), sizeof(*szInternalCmds), internal_match); - if (!nm || !(nm[0][0] & (nt ? 2 : 1))) + if (!nm || !(nm[0] & (nt ? 2 : 1))) return 0; return 1; }