History

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.

Thomas Preud'homme committed 12 years ago

Commit 6b7a6fc1 parent 356c6f61 file · +2 −26Browse files

Unified · Split

tccpp.c+2−26
@@ -2910,32 +2910,8 @@ static inline int *macro_twosharps(const int *macro_str) · 2909 unmodified lines
29102910 }
29112911 }
29122912 if (tok != TOK_NOSUBST) {
2913− const int *oldptr;
2914− CValue cval;
2915−
2916− /* Check if a space need to be added after ## concatenation in
2917− order to avoid misinterpreting the newly formed token
2918− followed by the next token as being a single token (see
2919− macro_concat test) */
2920− cstr_new(&cstr);
2921− cstr_cat(&cstr, get_tok_str(tok, &tokc));
2922− oldptr = ptr;
2923− TOK_GET(&t, &ptr, &cval);
2924− ptr = oldptr;
2925− cstr_cat(&cstr, get_tok_str(t, &cval));
2926− cstr_ccat(&cstr, '\0');
2927− t = tok;
2928− cval = tokc;
2929− tcc_open_bf(tcc_state, ":paste:", cstr.size);
2930− memcpy(file->buffer, cstr.data, cstr.size);
2931− next_nomacro1();
2932− if (!*file->buf_ptr) {
2933− tok_str_add2(&macro_str1, t, &cval);
2934− tok = ' ';
2935− }
2936− tcc_close();
2937− cstr_free(&cstr);
2938−
2913+ tok_str_add2(&macro_str1, tok, &tokc);
2914+ tok = ' ';
29392915 start_of_nosubsts = -1;
29402916 }
29412917 tok_str_add2(&macro_str1, tok, &tokc);

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