dissolve the hashtab nonsense, ¾ is good, and mirkev will also use that

This commit is contained in:
tg 2012-07-01 15:38:09 +00:00
parent c6edd7ebe6
commit 67714b270a
4 changed files with 19 additions and 29 deletions

23
main.c
View File

@ -34,7 +34,7 @@
#include <locale.h>
#endif
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.224 2012/06/28 20:05:08 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.225 2012/07/01 15:38:06 tg Exp $");
extern char **environ;
@ -238,8 +238,8 @@ main_init(int argc, const char *argv[], Source **sp, struct block **lp)
/* define built-in commands and see if we were called as one */
ktinit(APERM, &builtins,
/* currently up to 50 builtins */
/* 80% of 64 = 2^6 */ 6, /* 66% of 128 = 2^7 */ 7);
/* currently up to 50 builtins: 75% of 128 = 2^7 */
7);
for (i = 0; mkshbuiltins[i].name != NULL; i++)
if (!strcmp(ccp, builtin(mkshbuiltins[i].name,
mkshbuiltins[i].func)))
@ -267,10 +267,10 @@ main_init(int argc, const char *argv[], Source **sp, struct block **lp)
coproc_init();
/* set up variable and command dictionaries */
ktinit(APERM, &taliases, 0, 0);
ktinit(APERM, &aliases, 0, 0);
ktinit(APERM, &taliases, 0);
ktinit(APERM, &aliases, 0);
#ifndef MKSH_NOPWNAM
ktinit(APERM, &homedirs, 0, 0);
ktinit(APERM, &homedirs, 0);
#endif
/* define shell keywords */
@ -1598,13 +1598,8 @@ tgrow(struct table *tp)
/* table can get very full when reaching its size limit */
tp->nfree = (tp->tshift == 30) ? 0x3FFF0000UL :
/* but otherwise, only 80% (MKSH_SMALL) or 66% (normal) */
#ifdef MKSH_SMALL
((i * 4) / 5)
#else
((i * 2) / 3)
#endif
;
/* but otherwise, only 75% */
((i * 3) / 4);
tp->tbls = ntblp;
if (otblp == NULL)
return;
@ -1634,7 +1629,7 @@ tgrow(struct table *tp)
}
void
ktinit_real(Area *ap, struct table *tp, uint8_t initshift)
ktinit(Area *ap, struct table *tp, uint8_t initshift)
{
tp->areap = ap;
tp->tbls = NULL;

9
sh.h
View File

@ -157,7 +157,7 @@
#endif
#ifdef EXTERN
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.568 2012/06/28 20:17:37 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.569 2012/07/01 15:38:07 tg Exp $");
#endif
#define MKSH_VERSION "R40 2012/06/28"
@ -1816,12 +1816,7 @@ void coproc_write_close(int);
int coproc_getfd(int, const char **);
void coproc_cleanup(int);
struct temp *maketemp(Area *, Temp_type, struct temp **);
void ktinit_real(Area *, struct table *, uint8_t);
#ifdef MKSH_SMALL
#define ktinit(ap, tp, s80, s66) ktinit_real((ap), (tp), (s80))
#else
#define ktinit(ap, tp, s80, s66) ktinit_real((ap), (tp), (s66))
#endif
void ktinit(Area *, struct table *, uint8_t);
struct tbl *ktscan(struct table *, const char *, uint32_t, struct tbl ***);
/* table, name (key) to search for, hash(n) */
#define ktsearch(tp, s, h) ktscan((tp), (s), (h), NULL)

6
syn.c
View File

@ -23,7 +23,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/syn.c,v 1.76 2012/06/28 20:04:02 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/syn.c,v 1.77 2012/07/01 15:38:08 tg Exp $");
extern short subshell_nesting_level;
extern void yyskiputf8bom(void);
@ -810,8 +810,8 @@ initkeywords(void)
struct tbl *p;
ktinit(APERM, &keywords,
/* currently 28 keywords */
/* 80% of 64 = 2^6 */ 6, /* 66% of 64 = 2^6 */ 6);
/* currently 28 keywords: 75% of 64 = 2^6 */
6);
for (tt = tokentab; tt->name; tt++) {
if (tt->reserved) {
p = ktenter(&keywords, tt->name, hash(tt->name));

10
var.c
View File

@ -27,7 +27,7 @@
#include <sys/sysctl.h>
#endif
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.151 2012/06/28 20:02:29 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.152 2012/07/01 15:38:09 tg Exp $");
/*-
* Variables
@ -74,8 +74,8 @@ newblock(void)
l->argv = e->loc->argv;
}
l->exit = l->error = NULL;
ktinit(&l->area, &l->vars, 0, 0);
ktinit(&l->area, &l->funs, 0, 0);
ktinit(&l->area, &l->vars, 0);
ktinit(&l->area, &l->funs, 0);
l->next = e->loc;
e->loc = l;
}
@ -130,8 +130,8 @@ initvar(void)
struct tbl *tp;
ktinit(APERM, &specials,
/* currently 12 specials */
/* 80% of 16 = 2^4 */ 4, /* 66% of 32 = 2^5 */ 5);
/* currently 12 specials: 75% of 16 = 2^4 */
4);
while (i < V_MAX - 1) {
tp = ktenter(&specials, initvar_names[i],
hash(initvar_names[i]));