mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
fa1575d188
commit
c8141a8158
1 changed files with 5 additions and 4 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue