mirror of
https://github.com/frida/tinycc
synced 2025-01-01 09:34:29 +03: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) {
|
||||
const int *oldptr;
|
||||
CValue cval;
|
||||
|
||||
/* 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);
|
||||
|
||||
tok_str_add2(¯o_str1, tok, &tokc);
|
||||
tok = ' ';
|
||||
start_of_nosubsts = -1;
|
||||
}
|
||||
tok_str_add2(¯o_str1, tok, &tokc);
|
||||
|
Loading…
Reference in New Issue
Block a user