POV-Ray : Newsgroups : povray.general : #declaring pre-made macro for identical repeated use? : #declaring pre-made macro for identical repeated use? Server Time
30 Jul 2024 02:29:37 EDT (-0400)
  #declaring pre-made macro for identical repeated use?  
From: Kenneth
Date: 17 Dec 2009 11:00:00
Message: <web.4b2a53b4201783d65f302820@news.povray.org>
Hi all.

Let's say I've made a macro, and that I use it in the usual way in my scene (by
invoking it numerous times with different variables.)  But let's say I also need
to invoke the same macro hundreds of times *without* changing the variables (in
a #while loop for example.) Forget for the moment what the macro actually does;
I have a question about what would be the most computationally-efficient way to
invoke the macro in such a case.

Here's the way I would normally do it (this is a very simplistic example, just
to illustrate the idea):

#declare counter = 1;
#while(counter <= 200)
my_macro(1,2,3) // the same variables each time
#declare counter = counter + 1;
#end

Would it be more efficient to instead pre-#declare the macro with those set
variables, before using it in the #while loop? As in...

#declare my_identical_macro = macro(1,2,3);
Then using *that* in the #while loop. (Which does work, BTW.)

When #pre-declared this way, is there just one 'instance' of the macro now
(similar to calling a pre-#declared triangle mesh hundreds of times), making the
process faster and more efficient? Or is the macro repeatedly computed anyway,
like it normally would be?

Ken


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.