summaryrefslogtreecommitdiff
path: root/win32
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-02-24 04:51:39 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-02-24 04:51:39 +0000
commitc8141a8158c1690c048689358e637558f248c577 (patch)
tree74964104d1ba7017ab8a4b7d82377d5b0cce5043 /win32
parentfa1575d188e95767ac0193a2bf7751e1d00a05b2 (diff)
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
Diffstat (limited to 'win32')
-rw-r--r--win32/win32.c9
1 files 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;
}