Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between cfif not...EQ and cfif...NEQ?

Is there any difference (performance-wise, for example) between

<cfif not x EQ y>

and

<cfif x NEQ y> ?

like image 971
froadie Avatar asked Dec 09 '22 17:12

froadie


2 Answers

If there is any difference at all, I'd doubt you'd notice it unless you are running this many, many, many times or unless x and y are really processor intensive somehow. I've never seen this flagged as a possible performance issue with Coldfusion since MX 7.

I would recommend using the format that is the most readable to you. Adding bugs to your code by making it hard to read will be more of an impact than the performance differences of these two formats.

Personally, I'd prefer to see the NEQ version as it reads better and is more common in CF.

<cfif x NEQ y>

In my head reads, "If x not equal to y..." Whereas....

<cfif NOT x EQ y>

reads "if not x equal to y..." doesn't make sense in English.

like image 168
Dan Sorensen Avatar answered Dec 26 '22 21:12

Dan Sorensen


If you're really concerned about performance in these cases, you can use Compare or CompareNoCase are supposedly higher performing that EQ.

https://web.archive.org/web/20090212085046/http://livedocs.adobe.com/wtg/public/coding_standards/performance.html

But keep in mind those recommendations are from 5 years ago, and there is no more proof then this page that it is true.

like image 37
Terry Ryan Avatar answered Dec 26 '22 21:12

Terry Ryan