]> 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)
committerAlexei Sheplyakov <Alexei.Sheplyakov@gmail.com>
Thu, 9 Dec 2010 18:46:51 +0000 (20:46 +0200)
commita6e5a7a5974dc95afe71c077f6a5e66b322c9d2c
tree183e3f47610b55e3313a9a4e2f76c3da38651b48
parentab6a9475aef3d8f97a1b520731ad528603946410
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