even faster

This commit is contained in:
bellard 2001-12-06 23:57:36 +00:00
parent 711075fe3b
commit 5d7f7bb5ef

30
tcc.c
View file

@ -613,15 +613,11 @@ void sym_pop(SymStack *st, Sym *b)
st->top = b;
}
/* read next char from current input file */
void inp(void)
/* no need to put that inline */
int handle_eof(void)
{
redo:
/* faster than fgetc */
ch1 = getc_unlocked(file);
if (ch1 == -1) {
if (include_stack_ptr == include_stack)
return;
return -1;
/* pop include stack */
fclose(file);
free(filename);
@ -629,6 +625,19 @@ void inp(void)
file = include_stack_ptr->file;
filename = include_stack_ptr->filename;
line_num = include_stack_ptr->line_num;
return 0;
}
/* read next char from current input file */
static inline void inp(void)
{
redo:
/* faster than fgetc */
ch1 = getc_unlocked(file);
if (ch1 == -1) {
if (handle_eof() < 0)
return;
else
goto redo;
}
if (ch1 == '\n')
@ -637,7 +646,7 @@ void inp(void)
}
/* input with '\\n' handling */
void minp()
static inline void minp(void)
{
redo:
ch = ch1;
@ -649,8 +658,9 @@ void minp()
//printf("ch=%c 0x%x\n", ch, ch);
}
/* same as minp, but also skip comments */
void cinp()
void cinp(void)
{
int c;
@ -683,7 +693,7 @@ void cinp()
}
}
void skip_spaces()
void skip_spaces(void)
{
while (ch == ' ' || ch == '\t')
cinp();