]> www.ginac.de Git - ginac.git/commit
Fix the compliation error *for real* ... and restore performance
authorAlexei Sheplyakov <varg@metalica.kh.ua>
Sat, 8 Aug 2009 08:43:12 +0000 (11:43 +0300)
committerJens Vollinga <jensv@nikhef.nl>
Sun, 9 Aug 2009 20:27:50 +0000 (22:27 +0200)
commitaa1afbbdb118846cfc266a1d7a8d5188ac214e0e
treeacbfae9032e7b6fb7c78a681394469ac7b7c552e
parent14aeeca161c7cc2d145b0778ac234341068efef1
Fix the compliation error *for real* ... and restore performance

Commit 8bf0597dde55e4c94a2ff39f1d8130902e3d7a9b (titled as 'Fixed the parser
such that it can read in user defined classes again.') made the parser a bit
slower, especially if the input contains many terms of user-defined type.
The reason for that is quite simple: we throw and catch an exception every
time we construct an object of user-defined type:

       // dirty hack to distinguish between serial numbers of functions and real
       // pointers.
       GiNaC::function* f = NULL;
       try {
               unsigned serial = (unsigned)(unsigned long)(void *)(reader->second);
               f = new GiNaC::function(serial, args);
       }
       catch ( std::runtime_error ) {
               if ( f ) delete f;
               ex ret = reader->second(args);
               return ret;
       }

Fortunately functions are aligned and we can use much more efficient
technique to distinguish between serial and pointers to functions.
ginac/parser/default_reader.tpl
ginac/parser/parser.cpp