mirror of
https://github.com/mirror/tinycc.git
synced 2025-03-04 08:20:12 +08:00
Improve efficiency of macro concatenation
As per grischka comment, always output a space after macro concatenation instead of trying to detect if it's necessary as the current approach has a huge cost.
This commit is contained in:
parent
356c6f6293
commit
6b7a6fcbc8
28
tccpp.c
28
tccpp.c
@ -2910,32 +2910,8 @@ static inline int *macro_twosharps(const int *macro_str)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (tok != TOK_NOSUBST) {
|
if (tok != TOK_NOSUBST) {
|
||||||
const int *oldptr;
|
tok_str_add2(¯o_str1, tok, &tokc);
|
||||||
CValue cval;
|
tok = ' ';
|
||||||
|
|
||||||
/* Check if a space need to be added after ## concatenation in
|
|
||||||
order to avoid misinterpreting the newly formed token
|
|
||||||
followed by the next token as being a single token (see
|
|
||||||
macro_concat test) */
|
|
||||||
cstr_new(&cstr);
|
|
||||||
cstr_cat(&cstr, get_tok_str(tok, &tokc));
|
|
||||||
oldptr = ptr;
|
|
||||||
TOK_GET(&t, &ptr, &cval);
|
|
||||||
ptr = oldptr;
|
|
||||||
cstr_cat(&cstr, get_tok_str(t, &cval));
|
|
||||||
cstr_ccat(&cstr, '\0');
|
|
||||||
t = tok;
|
|
||||||
cval = tokc;
|
|
||||||
tcc_open_bf(tcc_state, ":paste:", cstr.size);
|
|
||||||
memcpy(file->buffer, cstr.data, cstr.size);
|
|
||||||
next_nomacro1();
|
|
||||||
if (!*file->buf_ptr) {
|
|
||||||
tok_str_add2(¯o_str1, t, &cval);
|
|
||||||
tok = ' ';
|
|
||||||
}
|
|
||||||
tcc_close();
|
|
||||||
cstr_free(&cstr);
|
|
||||||
|
|
||||||
start_of_nosubsts = -1;
|
start_of_nosubsts = -1;
|
||||||
}
|
}
|
||||||
tok_str_add2(¯o_str1, tok, &tokc);
|
tok_str_add2(¯o_str1, tok, &tokc);
|
||||||
|
Loading…
Reference in New Issue
Block a user