mirror of
https://github.com/netwide-assembler/nasm.git
synced 2024-11-21 03:14:19 +08:00
Slightly optimize the interface to nasm_token_hash()
Instead of returning -1 from nasm_token_hash, set tv->t_type to TOKEN_ID and return TOKEN_ID, since that's what stdscan.c wants to do with it anyway. This allows us to simply tailcall nasm_token_hash().
This commit is contained in:
parent
69db8c6963
commit
bf9a24f464
@ -75,7 +75,6 @@ int stdscan(void *private_data, struct tokenval *tv)
|
||||
(*stdscan_bufptr == '$' && isidstart(stdscan_bufptr[1]))) {
|
||||
/* now we've got an identifier */
|
||||
int is_sym = FALSE;
|
||||
int t;
|
||||
|
||||
if (*stdscan_bufptr == '$') {
|
||||
is_sym = TRUE;
|
||||
@ -99,10 +98,7 @@ int stdscan(void *private_data, struct tokenval *tv)
|
||||
*r = '\0';
|
||||
/* right, so we have an identifier sitting in temp storage. now,
|
||||
* is it actually a register or instruction name, or what? */
|
||||
if ((t = nasm_token_hash(ourcopy, tv)) != -1)
|
||||
return t;
|
||||
else
|
||||
return tv->t_type = TOKEN_ID;
|
||||
return nasm_token_hash(ourcopy, tv);
|
||||
} else if (*stdscan_bufptr == '$' && !isnumchar(stdscan_bufptr[1])) {
|
||||
/*
|
||||
* It's a $ sign with no following hex number; this must
|
||||
|
@ -194,14 +194,14 @@ print " }\n";
|
||||
print "\n";
|
||||
printf " ix = hash1[k1 & 0x%x] + hash2[k2 & 0x%x];\n", $n-1, $n-1;
|
||||
printf " if (ix >= %d)\n", scalar(@tokendata);
|
||||
print " return -1;\n";
|
||||
print " return tv->t_type = TOKEN_ID;\n";
|
||||
print "\n";
|
||||
print " data = &tokendata[ix];\n";
|
||||
|
||||
# print " fprintf(stderr, \"Looked for: %s found: %s\\n\", token, data->string);\n\n";
|
||||
|
||||
print " if (strcmp(data->string, token))\n";
|
||||
print " return -1;\n";
|
||||
print " return tv->t_type = TOKEN_ID;\n";
|
||||
print "\n";
|
||||
print " tv->t_integer = data->num;\n";
|
||||
print " tv->t_inttwo = data->aux;\n";
|
||||
|
Loading…
Reference in New Issue
Block a user