X-Git-Url: https://ginac.de/ginac.git/static/gitweb.css/ginac.git?a=blobdiff_plain;f=ginac%2Fremember.cpp;h=cdd346f74e0e1b18e32fe83e608c2c089039493f;hb=82fd1a4ad2f5d58a502a2ccc71be45093b282fea;hp=4995c8b11f26d10040a9787920a16929be8fe5b4;hpb=383d5eb3b0f0506810d9105a268f939125bfc347;p=ginac.git diff --git a/ginac/remember.cpp b/ginac/remember.cpp index 4995c8b1..cdd346f7 100644 --- a/ginac/remember.cpp +++ b/ginac/remember.cpp @@ -4,7 +4,7 @@ * in GiNaC functions */ /* - * GiNaC Copyright (C) 1999-2001 Johannes Gutenberg University Mainz, Germany + * GiNaC Copyright (C) 1999-2003 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,9 +27,7 @@ #include "utils.h" #include "remember.h" -#ifndef NO_NAMESPACE_GINAC namespace GiNaC { -#endif // ndef NO_NAMESPACE_GINAC ////////// // class remember_table_entry @@ -46,14 +44,15 @@ bool remember_table_entry::is_equal(function const & f) const { GINAC_ASSERT(f.seq.size()==seq.size()); if (f.gethash()!=hashvalue) return false; - for (unsigned i=0; i=max_assoc_size)) { // table is full, we must delete an older entry GINAC_ASSERT(size()>0); // there must be at least one entry @@ -122,11 +121,13 @@ void remember_table_list::add_entry(function const & f, ex const & result) bool remember_table_list::lookup_entry(function const & f, ex & result) const { - for (const_iterator cit=begin(); cit!=end(); ++cit) { - if ((*cit).is_equal(f)) { - result = (*cit).get_result(); + const_iterator i = begin(), iend = end(); + while (i != iend) { + if (i->is_equal(f)) { + result = i->get_result(); return true; } + ++i; } return false; } @@ -147,7 +148,7 @@ remember_table::remember_table(unsigned s, unsigned as, unsigned strat) { // we keep max_assoc_size and remember_strategy if we need to clear // all entries - + // use some power of 2 next to s table_size = 1 << log2(s); init_table(); @@ -186,6 +187,4 @@ std::vector & remember_table::remember_tables(void) return *rt; } -#ifndef NO_NAMESPACE_GINAC } // namespace GiNaC -#endif // ndef NO_NAMESPACE_GINAC