- lst::const_iterator its, itr;
- for (its = ls.begin(), itr = lr.begin(); its != ls.end(); ++its, ++itr) {
- if (is_equal(ex_to<basic>(*its))) {
-
- // Substitution index->index
- if (is_a<idx>(*itr))
- return *itr;
-
- // Otherwise substitute value
- idx *i_copy = duplicate();
- i_copy->value = *itr;
- i_copy->clearflag(status_flags::hash_calculated);
- return i_copy->setflag(status_flags::dynallocated);
- }
+ exmap::const_iterator it = m.find(*this);
+ if (it != m.end()) {
+
+ // Substitution index->index
+ if (is_a<idx>(it->second))
+ return it->second;
+
+ // Otherwise substitute value
+ idx *i_copy = duplicate();
+ i_copy->value = it->second;
+ i_copy->clearflag(status_flags::hash_calculated);
+ return i_copy->setflag(status_flags::dynallocated);