use reverse table to fix O(n^2) expansion of macro-introduced requires
svn: r10741
This commit is contained in:
parent
5860cb892a
commit
269423bf0d
|
@ -2015,6 +2015,13 @@ Scheme_Object *scheme_tl_id_sym(Scheme_Env *env, Scheme_Object *id, Scheme_Objec
|
||||||
map = scheme_make_pair(a, map);
|
map = scheme_make_pair(a, map);
|
||||||
|
|
||||||
scheme_hash_set(marked_names, sym, map);
|
scheme_hash_set(marked_names, sym, map);
|
||||||
|
{
|
||||||
|
Scheme_Hash_Table *rev_ht;
|
||||||
|
rev_ht = (Scheme_Hash_Table *)scheme_hash_get(marked_names, scheme_false);
|
||||||
|
if (rev_ht) {
|
||||||
|
scheme_hash_set(rev_ht, best_match, scheme_true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return best_match;
|
return best_match;
|
||||||
|
@ -2024,21 +2031,34 @@ int scheme_tl_id_is_sym_used(Scheme_Hash_Table *marked_names, Scheme_Object *sym
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
Scheme_Object *l, *a;
|
Scheme_Object *l, *a;
|
||||||
|
Scheme_Hash_Table *rev_ht;
|
||||||
|
|
||||||
if (!marked_names)
|
if (!marked_names)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
for (i = marked_names->size; i--; ) {
|
if (!marked_names->count)
|
||||||
l = marked_names->vals[i];
|
return 0;
|
||||||
if (l) {
|
|
||||||
for (; SCHEME_PAIRP(l); l = SCHEME_CDR(l)) {
|
rev_ht = (Scheme_Hash_Table *)scheme_hash_get(marked_names, scheme_false);
|
||||||
a = SCHEME_CAR(l);
|
|
||||||
if (SAME_OBJ(sym, SCHEME_CDR(a)))
|
if (!rev_ht) {
|
||||||
return 1;
|
rev_ht = scheme_make_hash_table(SCHEME_hash_ptr);
|
||||||
|
|
||||||
|
for (i = marked_names->size; i--; ) {
|
||||||
|
l = marked_names->vals[i];
|
||||||
|
if (l) {
|
||||||
|
for (; SCHEME_PAIRP(l); l = SCHEME_CDR(l)) {
|
||||||
|
a = SCHEME_CAR(l);
|
||||||
|
scheme_hash_set(rev_ht, SCHEME_CDR(a), scheme_true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
scheme_hash_set(marked_names, scheme_false, (Scheme_Object *)rev_ht);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (scheme_hash_get(rev_ht, sym))
|
||||||
|
return 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4830,7 +4830,9 @@ static Scheme_Object *wraps_to_datum(Scheme_Object *w_in,
|
||||||
Scheme_Object *d = scheme_null, *p;
|
Scheme_Object *d = scheme_null, *p;
|
||||||
|
|
||||||
for (i = mrn->marked_names->size; i--; ) {
|
for (i = mrn->marked_names->size; i--; ) {
|
||||||
if (mrn->marked_names->vals[i]) {
|
if (mrn->marked_names->vals[i]
|
||||||
|
/* #f mapping used to store reverse-map cache: */
|
||||||
|
&& !SCHEME_FALSEP(mrn->marked_names->keys[i])) {
|
||||||
p = CONS(mrn->marked_names->keys[i],
|
p = CONS(mrn->marked_names->keys[i],
|
||||||
mrn->marked_names->vals[i]);
|
mrn->marked_names->vals[i]);
|
||||||
d = CONS(p, d);
|
d = CONS(p, d);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user