Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 294794

Inversion and Ternary Operations

$
0
0

While looking over the code base I see many examples of this type of code

$var = !$condition ? 'if condition is false' : 'if condition is true';

I think this should have the negation removed.

It helps readability by a small amount sometimes but this is also a performance hit.

There are approximately 400 instances of this (with a few false positives)

grep -rsE '\![^=][^,]*\?.*:' . | wc -l

Viewing all articles
Browse latest Browse all 294794

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>