much better solution: save tablep and hash value¹ in the struct tbl entry
① also saves time during texpand :D XXX this doesn’t work well with the current indexed-array implementation
This commit is contained in:
10
lex.c
10
lex.c
@ -22,7 +22,7 @@
|
||||
|
||||
#include "sh.h"
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.91 2009/08/28 19:57:41 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.92 2009/08/28 20:30:56 tg Exp $");
|
||||
|
||||
/*
|
||||
* states while lexing word
|
||||
@ -909,17 +909,15 @@ yylex(int cf)
|
||||
|
||||
if (*ident != '\0' && (cf&(KEYWORD|ALIAS))) {
|
||||
struct tbl *p;
|
||||
struct table_entry te;
|
||||
uint32_t h = hash(ident);
|
||||
|
||||
/* { */
|
||||
if ((cf & KEYWORD) &&
|
||||
(p = ktsearch(&keywords, ident, h, NULL)) &&
|
||||
if ((cf & KEYWORD) && (p = ktsearch(&keywords, ident, h)) &&
|
||||
(!(cf & ESACONLY) || p->val.i == ESAC || p->val.i == '}')) {
|
||||
afree(yylval.cp, ATEMP);
|
||||
return (p->val.i);
|
||||
}
|
||||
if ((cf & ALIAS) && (p = ktsearch(&aliases, ident, h, &te)) &&
|
||||
if ((cf & ALIAS) && (p = ktsearch(&aliases, ident, h)) &&
|
||||
(p->flag & ISSET)) {
|
||||
/*
|
||||
* this still points to the same character as the
|
||||
@ -946,7 +944,7 @@ yylex(int cf)
|
||||
* delete alias upon encountering function
|
||||
* definition
|
||||
*/
|
||||
ktremove(&te);
|
||||
ktdelete(p);
|
||||
else {
|
||||
Source *s = source;
|
||||
|
||||
|
Reference in New Issue
Block a user