lundi 25 janvier 2016

Perl If/Else Optimization

Suppose I have a string $a = "abc";

In terms of optimization and speed, would it be faster if I ran

if ($a ne "abc") {
    print "Not abc";
} else {
    print "abc";
}

Versus

if ($a eq "abc") {
    print "abc";
} else {
    print "Not abc";
}

? I am asking because I have a loop that will typically enter the else statement and I wanted to know if I could make it run more efficiently by switching the if/else clauses

Aucun commentaire:

Enregistrer un commentaire