Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added a cache for lab color values to prevent calculating the same co…

…lor values multiple times
  • Loading branch information...
commit b662ab11f2a1733d541a3cfa2184d20a852ef5c1 1 parent be8f116
@lencioni authored
Showing with 11 additions and 4 deletions.
  1. +11 −4 core/libs/gd/croppers/smart.class.php
View
15 core/libs/gd/croppers/smart.class.php
@@ -61,6 +61,11 @@ class SLIRCropperSmart implements SLIRCropper
private $colors;
/**
+ * @var array Cached LAB color values for integer color indexes
+ */
+ private $labColors;
+
+ /**
* Destruct method. Try to clean up memory a little.
*
* @return void
@@ -428,11 +433,13 @@ private function calculateInterestingness($x, $y)
*/
private function evaluateColor($int)
{
- $rgb = $this->colorIndexToRGB($int);
- $xyz = $this->RGBtoXYZ($rgb);
- $lab = $this->XYZtoHunterLab($xyz);
+ if (!isset($this->labColors[$int])) {
+ $rgb = $this->colorIndexToRGB($int);
+ $xyz = $this->RGBtoXYZ($rgb);
+ $this->labColors[$int] = $this->XYZtoHunterLab($xyz);
+ }
- return $lab;
+ return $this->labColors[$int];
}
/**
Please sign in to comment.
Something went wrong with that request. Please try again.