diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2014-02-14 17:42:08 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2014-02-14 17:42:08 -0800 |
commit | 6b4e2804f2da87aa3d15d407acc9b774a01d1555 (patch) | |
tree | 82d5a1768cb57c743f53a398cb141b3fded30fda /lib.c | |
parent | a4b872687408e7624ccb500fbce8467ae3f821e6 (diff) | |
download | txr-6b4e2804f2da87aa3d15d407acc9b774a01d1555.tar.gz txr-6b4e2804f2da87aa3d15d407acc9b774a01d1555.tar.bz2 txr-6b4e2804f2da87aa3d15d407acc9b774a01d1555.zip |
Replacing acons_new_l and aconsq_new_l interfaces with ones
that return the new or old cons cell rather than a pointer
to its cdr field.
* eval.c (transform_op): use of acons_new_l replaced with
acons_new_c.
* hash.c (struct hash): acons_new_l_fun member replaced
with acons_new_c_fun.
(make_hash, make_similar_hash): initialize acons_new_l_fun
member using either acons_new_c or aconsql_new_c.
(gethash_l): function becomes an inline in hash.h.
(gethash_c): new function, based on gethash_l.
(inhash, gethash_n): updated w.r.t struct hash change.
* hash.h (gethash_c): declared.
(gethash_l): becomes an inline wrapper for gethash_c.
* lib.c (acons_new_l, aconsql_new_l): functions removed.
(acons_new_c, aconsql_new_c): new functions.
(obj_init): use gethash_c and rplacd instead of gethash_l
and set.
* lib.h (acons_new_l, aconsql_new_l): declarations removed.
(acons_new_c, aconsql_new_c): declared.
Diffstat (limited to 'lib.c')
-rw-r--r-- | lib.c | 19 |
1 files changed, 10 insertions, 9 deletions
@@ -4468,20 +4468,20 @@ val acons_new(val key, val value, val list) } } -val *acons_new_l(val key, val *new_p, val *list) +val acons_new_c(val key, val *new_p, val *list) { val existing = assoc(key, *list); if (existing) { if (new_p) *new_p = nil; - return cdr_l(existing); + return existing; } else { val nc = cons(key, nil); set(*list, cons(nc, *list)); if (new_p) *new_p = t; - return cdr_l(nc); + return nc; } } @@ -4497,20 +4497,20 @@ val aconsql_new(val key, val value, val list) } } -val *aconsql_new_l(val key, val *new_p, val *list) +val aconsql_new_c(val key, val *new_p, val *list) { val existing = assql(key, *list); if (existing) { if (new_p) *new_p = nil; - return cdr_l(existing); + return existing; } else { val nc = cons(key, nil); set(*list, cons(nc, *list)); if (new_p) *new_p = t; - return cdr_l(nc); + return nc; } } @@ -5073,10 +5073,11 @@ static void obj_init(void) /* nil can't be interned because it's not a SYM object; it works as a symbol because the nil case is handled by symbol-manipulating function. */ - *gethash_l(user_package->pk.symhash, nil_string, 0) = nil; + rplacd(gethash_c(user_package->pk.symhash, nil_string, 0), nil); - /* t can't be interned, because gethash_l needs t in order to do its job. */ - t = set(*gethash_l(user_package->pk.symhash, lit("t"), 0), make_sym(lit("t"))); + /* t can't be interned, because intern needs t in order to do its job. */ + t = rplacd(gethash_c(user_package->pk.symhash, + lit("t"), 0), make_sym(lit("t"))); set(t->s.package, user_package); null = intern(lit("null"), user_package); |