PoC: Cached function calls

Chris Nicholson-Sauls ibisbasenji at gmail.com
Sun Dec 17 10:52:16 PST 2006


janderson wrote:
> Nice, I really like these type of algorithms.  I once wrote a C++ one to 
> move the vtable of objects to a local area in memory to avoid double 
> seeking.   One optimisation you may consider (if it hasn't already been 
> added is:
> 
> Change
>  > #         p_cache[node] = Func(args);
>  > #         result = node in p_cache;
> 
> To
> 
>  > #         result = Func(args);
>  > #        p_cache[node] = result;

Actually I ended up changing these to 'return p_cache[node] = Func(args);'.  Even quicker. 
  :)  The only problem with your suggested way is that 'result' is a pointer, and I can't 
take the address of a return value (I don't think...).

-- Chris Nicholson-Sauls



More information about the Digitalmars-d mailing list