On Sep 2, 2006, at 1:53 PM, Arnaud Nicolet wrote:

Le 1 sept. 06 à 21:49 Soir, Brendan Murphy a écrit:

OK, this if for the newbies to REALbasic out there. Here are some
common tricks for speeding up your code. I have listed some of the
most common tricks I have seen and used. If anybody else any other
tricks that they would like to share, please feel free to share
them. An old dog can learn new tricks!

Also, when you use "if" expressions where a boolean is evaluated, you should avoid using "=true" or "=false".

Slower:

dim b as boolean

if b=true then
DoSomething
end if

Faster:

dim b as boolean

if b then
DoSomething
end if

I doubt if it is that much faster unless it is in an extended loop. Maybe a few milliseconds. It is easier to type, however.

The slowest method first evaluates "b", then evaluates "true" and then checks for the equality. It does "DoSomething" if the equality is true.

The fastest method evaluates "b". It does "DoSomething" if "b" is true.

For false, use

if not b then

instead of

if b=false then.

Same answer.

But I don't know if

if b=false then

is faster than

if not b<>not true then
I wonder.

It compiles and is valid if b=False but is quite unusual usage. Using parentheses it would look like:

If Not(b<>(not (true))) Then

Faster? Probably not consequential. Confusing? Most definitely.

Terry

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to