1.2.1106. Should Cache Local¶
Repeated calls to a method with the same arguments should be put in a local cache.
It speeds up processing, even in case of a simple property fetch. A local cache makes the code more readable and more compact.
<?php
function foo() {
$goo = goo(), 0, 3;
$a = strtolower($goo);
$b = strtoupper($goo);
return $a . '-' . $b;
}
function foo2() {
$a = strtolower(goo(), 0, 3);
$b = strtoupper(goo(), 0, 3);
return $a . '-' . $b;
}
?>
1.2.1106.1. Connex PHP features¶
1.2.1106.1.1. Suggestions¶
Use a local cache to reduce processing time
1.2.1106.1.2. Specs¶
Short name |
Performances/ShouldCacheLocal |
Rulesets |
|
Exakat since |
2.5.2 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Quick (30 mins) |
Precision |
Medium |
Available in |