POV-Ray : Newsgroups : povray.general : A couple parser performance issues/optimizations. : Re: A couple parser performance issues/optimizations. Server Time
19 May 2024 02:20:21 EDT (-0400)
  Re: A couple parser performance issues/optimizations.  
From: Alain
Date: 11 Oct 2017 18:54:01
Message: <59dea109$1@news.povray.org>
Le 17-10-11 à 05:44, Kenneth a écrit :
> 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.
> 
> 

With some interpreted languages with some kind of bitcompiling, I 
remember Applesoft BASIC, the programms are in a linked list format, 
where each line have a header containing a pointer to the next line. In 
that case, when you have a comment, it's easy to jump to the next line 
as you aleready know where it start.

When the code is in text form, without any pointer to the next part of 
the code, you can't jump forward and are forced to actually read the 
comments to find where they end.


Post a reply to this message

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