[Gambas-user] IF and AND - what is more efficient?

Rolf-Werner Eilert eilert-sprachen at ...221...
Thu Jun 7 09:38:59 CEST 2007


Good morning everyone,

as I don't know how the Gambas interpreter handles AND clauses in IF 
conditions, this is where I just was contemplating about:

Let's assume I've got three different strings to compare which are in a 
table-like structure. Only when all the three strings are right, the app 
is to do something with it. The priorities are that there are a lot of 
entries with string1, fewer ones with string2 and the least with 
string3, so it's advisable to sort out string1 first, then string2 and 
string3 as the last one. The table is rather long, and I want to save 
time and processor load :-)

Sure it would be ok to write

IF string1 = "xyz" AND string2 = "abc" AND string3 = "www" THEN

but would the interpreter try to check all the three before deciding to 
skip the block? Might it be more advisable to check it like

IF string1 = "xyz" THEN
	IF string2 = "abc" THEN
		IF string3 = "www" THEN

so it wouldn't jump to the next condition at all? Or is THIS the less 
efficient version because of something I don't know?

Regards

Rolf




More information about the User mailing list