[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Removing debug assertions
- From: "David Burgess" <dburgess@...>
- Date: Thu, 10 May 2007 22:43:15 +1000
You could also try the C preprocessor.
On 5/10/07, David Haley <email@example.com> wrote:
Is there a 'good' way of removing assertions from code at run/compile
time? I want to keep them around in the source so that I can use them
for debugging, but I'd also like to turn them off to make things as fast
as possible (I am testing something for performance). I poked around in
the mailing list archives and on Google but didn't see anything.
Ideally, everything inside the assert would simply disappear, so that
the error message would not have to be constructed either.
For instance, this entire statement should just disappear:
assert(self.assignment[var] == nil, "var '" .. var .. "' already had
value '" .. (self.assignment[var] or "nil") .. "'")
One solution would be to preprocess the source using e.g. a perl script
and pipe that to luac. Then I would run from source when debugging and
from bytecode when timing. Is this a reasonable idea?