Which is faster?

We have situation when we need to set about 10 filters from variables. So in coding process the interesting question showed up: Which code is faster: IF CustomerFilter <> '' THEN SETFILTER("Customer No.",CustomerFilter); OR SETFILTER("Customer No.",CustomerFilter); Pay attention that in the first case no filter will be set while in second filter will be set empty one. There isn’t any big sense in this question… so take it easy [:)]

Well… it depends. (According to Dilbert’s “Understanding technical people”, this statement actually means “Abandon all hope of a useful answer” [:p]) If CustomerFilter will be empty most of the time, the first variant will be faster, as this will prevent you from setting unnecessary filters. I presume that a string comparison on the empty string is faster than setting a filter. If, however, CustomerFilter will be non-empty in most cases, version 1 will be slower, as you will perform a test in addition to setting a filter which you would have set anyways. But then, as you mentioned already - the two variants are not equivalent (no filter vs. filter on empty string), so why bother about which is faster when the result will be different? [:D]

quote:


Originally posted by xorph
But then, as you mentioned already - the two variants are not equivalent (no filter vs. filter on empty string), so why bother about which is faster when the result will be different? [:D]


By “filter on empty string” I ment that the filter will be set from empty string (variable) and the result will be “no filter set”. So the result of codes will be the same. And in 2nd code I can save one line of code and some bytes of object size [:D]

quote:


Originally posted by Arthur
So the result of codes will be the same.


You are right, Arthur. Silly me. [:I]

quote:


And in 2nd code I can save one line of code and some bytes of object size [:D]


Yeah, but you asked which one was faster, not which one was smaller [:D] Welcome to the EU, by the way! I hope flights to the Baltic will get cheaper soon. After reading a story about Riga in a local newspaper, we almost booked a flight there for Passover, but decided that it was still a bit expensive for the three of us (full fare for our child [:(]).