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.
master
Thomas Preud'homme 2014-04-14 20:45:10 +08:00
parent 356c6f6293
commit 6b7a6fcbc8
1 changed files with 2 additions and 26 deletions

28
tccpp.c
View File

@ -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(&macro_str1, t, &cval);
tok = ' ';
}
tcc_close();
cstr_free(&cstr);
tok_str_add2(&macro_str1, tok, &tokc);
tok = ' ';
start_of_nosubsts = -1;
}
tok_str_add2(&macro_str1, tok, &tokc);