Category Archives: concepts and principles

Improving performance with return values caching

Many functions (and methods) in a project will often provide the same return value for the same arguments, like:

  • mathematical functions:
1
2
3
4
function someMaths($x)
{
    return $x + pow($x, 3.2) - cos($x);
}
  • functions which retrieve content from a file:

Continue reading