Please remove ?:

Lionello Lunesu lionello at lunesu.remove.com
Sat Jun 3 00:42:12 PDT 2006


> What makes me wonder is why ?: looks faster. Does * look faster than /, 
> then?
> Yet, it is on modern PCs. In my humble opinion, a programmer should not,
> generally speaking, judge expressions' performance by how many words or 
> keywords
> are used.

When I'm writing libraries, I tend to give longer, complicated names to 
functions that are slow. People using libraries don't know the performance 
of a function, and with all that intellisense stuff, they don't read the 
docs. If you have an array and want to check whether it contains item X, 
they select "Contains(X)" from the intellisense popup and that's that. I had 
to rename the function to get it through to them that you don't want to be 
calling Contains(X) (doing a linear search) in an inner loop :S

Similarly, I think ?: looks faster than if...else but it's exactly the same 
construct (ok, ?: can also be an rvalue), resulting in the same code. * and 
/ both result in 1 cpu instruction; 1 token -> 1 instruction seems perfect 
: )

L. 





More information about the Digitalmars-d mailing list