Asger Ottar Alstrup wrote:

> I guess that's what the person who wrote debugstream thought. "This is
> probably good enough."

It is IMO a nice solution for outputting simple stuff without plastering the
code with if(). The problem it has is that the right hand side is always
computed, even if the output is discarded. But if one keeps that in mind it
is a good debug utility.

> But that person forgot to have a look at 
> nullstream. It is a piece of absolute crap.

You can certainly backup that statement with measurements or other evidence?
Otherwise it falls back on yourself.

> So it boils down to a very simple message for all coders here:
> 
>       ** Don't use lyxerr[] in a critical code path. ***

Wrong. Right is:

Don't use any lyxerr in a critical code path at all, and don't use lyxerr[]
anywhere if the right hand side is expensive to compute.

lyxerr[Debug::PAINTING] << "Painting at x = " << x << ", y = " << y << '\n';

where x and y are simple numbers is pretty cheap.

We have several commented lyxerr statements in the code in performance
critical sections. They are commented and not used with [] exactly for
performance reasons.

I think the main problem is that many debug statements have been added
lately by people who where not aware how lyxerr really works.


Georg

Reply via email to