From 14f8b96b563dda9f7d61f5dc1cde14436ef6ea69 Mon Sep 17 00:00:00 2001 From: "kr.angelov" Date: Thu, 5 Sep 2013 13:34:49 +0000 Subject: remove the string internalization since it slows down grammar loading with little benefit --- src/runtime/c/gu/intern.c | 59 ----------------------------------------------- src/runtime/c/gu/intern.h | 24 ------------------- 2 files changed, 83 deletions(-) delete mode 100644 src/runtime/c/gu/intern.c delete mode 100644 src/runtime/c/gu/intern.h (limited to 'src/runtime/c/gu') diff --git a/src/runtime/c/gu/intern.c b/src/runtime/c/gu/intern.c deleted file mode 100644 index 35eaa1c5f..000000000 --- a/src/runtime/c/gu/intern.c +++ /dev/null @@ -1,59 +0,0 @@ -#include "intern.h" - -struct GuIntern { - GuPool* str_pool; - GuMap* map; -}; - -GuIntern* -gu_new_intern(GuPool* str_pool, GuPool* pool) -{ - GuIntern* intern = gu_new(GuIntern, pool); - intern->str_pool = str_pool; - intern->map = gu_new_set(const char*, gu_str_hasher, pool); - return intern; -} - -const char* -gu_intern_str(GuIntern* intern, const char* cstr) -{ - const char* const* strp = gu_map_find_key(intern->map, &cstr); - if (strp) { - return *strp; - } - const char* str = gu_strdup(cstr, intern->str_pool); - gu_map_insert(intern->map, &str); - return str; -} - - - - -struct GuSymTable { - GuPool* sym_pool; - GuMap* map; -}; - -GuSymTable* -gu_new_symtable(GuPool* sym_pool, GuPool* pool) -{ - GuSymTable* tab = gu_new(GuSymTable, pool); - tab->sym_pool = sym_pool; - tab->map = gu_new_set(GuSymbol, gu_string_hasher, pool); - return tab; -} - -GuSymbol -gu_symtable_intern(GuSymTable* tab, GuString string) -{ - if (gu_string_is_stable(string)) { - return string; - } - const GuSymbol* symp = gu_map_find_key(tab->map, &string); - if (symp) { - return *symp; - } - GuSymbol sym = gu_string_copy(string, tab->sym_pool); - gu_map_insert(tab->map, &sym); - return sym; -} diff --git a/src/runtime/c/gu/intern.h b/src/runtime/c/gu/intern.h deleted file mode 100644 index bf9e9b321..000000000 --- a/src/runtime/c/gu/intern.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef GU_INTERN_H_ -#define GU_INTERN_H_ - -#include -#include -#include - -typedef struct GuIntern GuIntern; - -GuIntern* gu_new_intern(GuPool* str_pool, GuPool* pool); -const char* gu_intern_str(GuIntern* intern, const char* cstr); - - -typedef struct GuSymTable GuSymTable; - -typedef GuString GuSymbol; - -GuSymTable* -gu_new_symtable(GuPool* sym_pool, GuPool* pool); - -GuSymbol -gu_symtable_intern(GuSymTable* symtab, GuString string); - -#endif /* GU_INTERN_H_ */ -- cgit v1.2.3