From 582cf626ea86d8b24bdb2de227cb0c1f6767a1a9 Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Tue, 26 Aug 2014 13:30:34 +0900 Subject: [PATCH] refactor import_table --- lib.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib.c b/lib.c index 45351083..41202426 100644 --- a/lib.c +++ b/lib.c @@ -74,6 +74,7 @@ import_table(pic_state *pic, pic_value spec) struct pic_lib *lib; struct pic_dict *imports, *dict; pic_value val, id; + pic_sym sym; xh_iter it; imports = pic_dict_new(pic); @@ -99,7 +100,10 @@ import_table(pic_state *pic, pic_value spec) dict = import_table(pic, pic_cadr(pic, spec)); xh_begin(&it, &dict->hash); while (xh_next(&it)) { - pic_dict_set(pic, imports, pic_intern_cstr(pic, pic_str_cstr(pic_strcat(pic, pic_str_new_cstr(pic, pic_symbol_name(pic, pic_sym(pic_car(pic, pic_cddr(pic, spec))))), pic_str_new_cstr(pic, pic_symbol_name(pic, xh_key(it.e, pic_sym)))))), xh_val(it.e, pic_value)); + id = pic_sym_value(xh_key(it.e, pic_sym)); + val = pic_list_ref(pic, spec, 2); + sym = pic_intern_str(pic, pic_format(pic, "~s~s", val, id)); + pic_dict_set(pic, imports, sym, xh_val(it.e, pic_value)); } return imports; }