ruby-changes:37633
From: nobu <ko1@a...>
Date: Tue, 24 Feb 2015 13:51:53 +0900 (JST)
Subject: [ruby-changes:37633] nobu:r49714 (trunk): win32.c: reduce memory size
nobu 2015-02-24 13:51:39 +0900 (Tue, 24 Feb 2015) New Revision: 49714 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=49714 Log: 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. Modified files: trunk/win32/win32.c Index: win32/win32.c =================================================================== --- win32/win32.c (revision 49713) +++ win32/win32.c (revision 49714) @@ -865,7 +865,8 @@ FindFreeChildSlot(void) https://github.com/ruby/ruby/blob/trunk/win32/win32.c#L865 -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[ https://github.com/ruby/ruby/blob/trunk/win32/win32.c#L922 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) https://github.com/ruby/ruby/blob/trunk/win32/win32.c#L973 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; } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/