From 224236f57c7d645c9b23d717de354df5d12b98b6 Mon Sep 17 00:00:00 2001 From: Vlad Vissoultchev Date: Sun, 17 Apr 2016 16:37:23 +0300 Subject: Improve hash performance - better `TOK_HASH_FUNC` - increases `hash_ident` initial size to 16k (from 8k) - `cstr_cat` uses single `realloc` + `memcpy` - `cstr_cat` can append terminating zero - `tok_str_realloc` initial size to 16 (from 8) - `parse_define` uses static `tokstr_buf` - `next` uses static `tokstr_buf` - fixes two latent bugs (wrong deallocations in libtcc.c:482 and tccpp.c:2987) --- i386-asm.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'i386-asm.c') diff --git a/i386-asm.c b/i386-asm.c index 68a7861..772b74a 100644 --- a/i386-asm.c +++ b/i386-asm.c @@ -1300,7 +1300,7 @@ ST_FUNC void subst_asm_operand(CString *add_str, if (!(r & VT_LVAL) && modifier != 'c' && modifier != 'n') cstr_ccat(add_str, '$'); if (r & VT_SYM) { - cstr_cat(add_str, get_tok_str(sv->sym->v, NULL)); + cstr_cat(add_str, get_tok_str(sv->sym->v, NULL), -1); if ((uint32_t)sv->c.i != 0) { cstr_ccat(add_str, '+'); } else { @@ -1311,17 +1311,17 @@ ST_FUNC void subst_asm_operand(CString *add_str, if (modifier == 'n') val = -val; snprintf(buf, sizeof(buf), "%d", (int)sv->c.i); - cstr_cat(add_str, buf); + cstr_cat(add_str, buf, -1); } else if ((r & VT_VALMASK) == VT_LOCAL) { snprintf(buf, sizeof(buf), "%d(%%ebp)", (int)sv->c.i); - cstr_cat(add_str, buf); + cstr_cat(add_str, buf, -1); } else if (r & VT_LVAL) { reg = r & VT_VALMASK; if (reg >= VT_CONST) tcc_error("internal compiler error"); snprintf(buf, sizeof(buf), "(%%%s)", get_tok_str(TOK_ASM_eax + reg, NULL)); - cstr_cat(add_str, buf); + cstr_cat(add_str, buf, -1); } else { /* register case */ reg = r & VT_VALMASK; @@ -1378,7 +1378,7 @@ ST_FUNC void subst_asm_operand(CString *add_str, #endif } snprintf(buf, sizeof(buf), "%%%s", get_tok_str(reg, NULL)); - cstr_cat(add_str, buf); + cstr_cat(add_str, buf, -1); } } -- cgit v1.3.1