History

even faster

bellard committed 24 years ago

Commit 5d7f7bb1 parent 711075f1 file · +29 −19Browse files

Unified · Split

tcc.c+29−19
@@ -613,23 +613,32 @@ void sym_pop(SymStack *st, Sym *b) · 612 unmodified lines
613613 st->top = b;
614614 }
615615
616+/* no need to put that inline */
617+int handle_eof(void)
618+{
619+ if (include_stack_ptr == include_stack)
620+ return -1;
621+ /* pop include stack */
622+ fclose(file);
623+ free(filename);
624+ include_stack_ptr--;
625+ file = include_stack_ptr->file;
626+ filename = include_stack_ptr->filename;
627+ line_num = include_stack_ptr->line_num;
628+ return 0;
629+}
630+
616631 /* read next char from current input file */
617−void inp(void)
632+static inline void inp(void)
618633 {
619634 redo:
620635 /* faster than fgetc */
621636 ch1 = getc_unlocked(file);
622637 if (ch1 == -1) {
623− if (include_stack_ptr == include_stack)
638+ if (handle_eof() < 0)
624639 return;
625− /* pop include stack */
626− fclose(file);
627− free(filename);
628− include_stack_ptr--;
629− file = include_stack_ptr->file;
630− filename = include_stack_ptr->filename;
631− line_num = include_stack_ptr->line_num;
632− goto redo;
640+ else
641+ goto redo;
633642 }
634643 if (ch1 == '\n')
635644 line_num++;
@@ -637,9 +646,9 @@ void inp(void) · 1 unmodified line
637646 }
638647
639648 /* input with '\\n' handling */
640−void minp()
649+static inline void minp(void)
641650 {
642− redo:
651+ redo:
643652 ch = ch1;
644653 inp();
645654 if (ch == '\\' && ch1 == '\n') {
@@ -649,8 +658,9 @@ void minp() · 3 unmodified lines
649658 //printf("ch=%c 0x%x\n", ch, ch);
650659 }
651660
661+
652662 /* same as minp, but also skip comments */
653−void cinp()
663+void cinp(void)
654664 {
655665 int c;
656666
@@ -669,11 +679,11 @@ void cinp() · 12 unmodified lines
669679 while (ch1 != -1) {
670680 c = ch1;
671681 inp();
672− if (c == '*' && ch1 == '/') {
673− inp();
674− ch = ' '; /* return space */
675− break;
676− }
682+ if (c == '*' && ch1 == '/') {
683+ inp();
684+ ch = ' '; /* return space */
685+ break;
686+ }
677687 }
678688 } else {
679689 ch = '/';
@@ -683,7 +693,7 @@ void cinp() · 3 unmodified lines
683693 }
684694 }
685695
686−void skip_spaces()
696+void skip_spaces(void)
687697 {
688698 while (ch == ' ' || ch == '\t')
689699 cinp();

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t