--- cvsroot/microscheme/scheme.c 2015/11/28 10:59:14 1.33 +++ cvsroot/microscheme/scheme.c 2015/11/28 22:14:49 1.34 @@ -1081,6 +1081,16 @@ /* ========== oblist implementation ========== */ +static pointer +generate_symbol (SCHEME_P_ const char *name) +{ + pointer x = mk_string (SCHEME_A_ name); + setimmutable (x); + x = immutable_cons (x, NIL); + set_typeflag (x, T_SYMBOL); + return x; +} + #ifndef USE_OBJECT_LIST static int @@ -1105,13 +1115,8 @@ static pointer oblist_add_by_name (SCHEME_P_ const char *name) { - int location; - - pointer x = immutable_cons (mk_string (SCHEME_A_ name), NIL); - set_typeflag (x, T_SYMBOL); - setimmutable (car (x)); - - location = hash_fn (name, veclength (SCHEME_V->oblist)); + pointer x = generate_symbol (SCHEME_A_ name); + int location = hash_fn (name, veclength (SCHEME_V->oblist)); vector_set (SCHEME_V->oblist, location, immutable_cons (x, vector_get (SCHEME_V->oblist, location))); return x; } @@ -1373,23 +1378,10 @@ gensym (SCHEME_P) { pointer x; + char name[40] = "gensym-"; + xnum (name + 7, SCHEME_V->gensym_cnt); - for (; SCHEME_V->gensym_cnt < LONG_MAX; SCHEME_V->gensym_cnt++) - { - char name[40] = "gensym-"; - xnum (name + 7, SCHEME_V->gensym_cnt); - - /* first check oblist */ - x = oblist_find_by_name (SCHEME_A_ name); - - if (x == NIL) - { - x = oblist_add_by_name (SCHEME_A_ name); - return x; - } - } - - return NIL; + return generate_symbol (SCHEME_A_ name); } /* make symbol or number atom from string */