refactors u3v_wish for clarity

This commit is contained in:
Joe Bryan 2018-10-28 20:53:02 -04:00
parent 999e82a44a
commit b88a2b5062

View File

@ -89,33 +89,22 @@ u3v_start(u3_noun now)
u3_noun
u3v_wish(const c3_c* str_c)
{
u3_noun exp;
u3_noun txt = u3i_string(str_c);
u3_weak exp = u3kdb_get(u3k(u3A->yot), u3k(txt));
if ( u3R == &u3H->rod_u ) {
u3_noun txt = u3i_string(str_c);
exp = u3kdb_get(u3k(u3A->yot), u3k(txt));
if ( u3_none == exp ) {
exp = _cv_nock_wish(u3k(txt));
if ( u3_none == exp ) {
exp = _cv_nock_wish(u3k(txt));
// It's probably not a good idea to use u3v_wish()
// outside the top level... (as the result is uncached)
//
if ( u3R == &u3H->rod_u ) {
u3A->yot = u3kdb_put(u3A->yot, u3k(txt), u3k(exp));
}
u3z(txt);
return exp;
}
else {
// It's probably not a good idea to use u3v_wish()
// outside the top level...
//
u3_noun txt = u3i_string(str_c);
u3_noun exp = u3kdb_get(u3A->yot, u3k(txt));
if ( u3_none != exp ) {
u3z(txt);
return exp;
}
else return _cv_nock_wish(u3i_string(str_c));
}
u3z(txt);
return exp;
}
/* _cv_mung(): formula wrapper with gate and sample.