POV-Ray : Newsgroups : povray.general : A couple parser performance issues/optimizations. : Re: A couple parser performance issues/optimizations. Server Time
2 May 2024 11:08:39 EDT (-0400)
  Re: A couple parser performance issues/optimizations.  
From: Kenneth
Date: 11 Oct 2017 05:50:01
Message: <web.59dde80931ae2f1289df8d30@news.povray.org>
Alain <kua### [at] videotronca> wrote:
> Le 17-10-07 à 19:00, Bald Eagle a écrit :
> > William F Pokorny <ano### [at] anonymousorg> wrote:
> >>
> >> 1) Comments in inner loops are costly.
> >
> > I would not have guessed that.  I had always imagined that it bailed out
> > as soon as it saw  //  but I guess not.
>
> It does ignore whatever is in the comment, but, it have to pace through
> the comment character by character to find exactly where it ends. In a
> loop, it add up quickly.
>

Thanks, Alain. That explains my own longer parse times when using lots of
comments in a scene, the reason for which has been a mystery to me for years--
because the documentation makes a point of saying "comments are ignored by the
raytracer" and "Use comments liberally and generously." ;-)

My own (false) understanding was that a  // or  /* comment indicator somehow
caused the parser to actually *skip* all of the following text, or until it hit
another 'closing' */ indicator-- kind of like a  'goto'  statement in other
languages, or like POV's macro-invocation behavior, where the parser immediately
jumps to the macro itself. But it makes sense that the parser has to 'read' the
intervening text-- at least when using  /*  and  */ --in order to know WHERE the
closing comment is! For single-line  // comments, though, I would have imagined
that all the text on that particular line would BE ignored, as soon as the
parser came across a double slash //  Hmm, apparently not.

I need to look through my scenes to try and eliminate as many unnecessary
comments as possible in any #while/#for loops, and in any #macros that are
called multiple times.


Post a reply to this message

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