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