@@ -14,6 +14,7 @@ class Spriter {
1414 protected $ cssDirectory ;
1515 protected $ spriteFilepath ;
1616 protected $ spriteFilename ;
17+ protected $ spriteChecksum = false ;
1718 protected $ tileMargin = 0 ;
1819 protected $ retina = array ( 1 );
1920 protected $ retinaDelimiter = "@ " ;
@@ -48,9 +49,9 @@ public function __construct( $config = array() ) {
4849 // setup & generation
4950 $ this ->setupIcons ();
5051 if ( $ this ->hasChanged () || $ this ->forceGenerate ) {
52+ $ this ->generateChecksum ();
5153 $ this ->generateSprite ();
5254 $ this ->generateCSS ();
53- $ this ->generateChecksum ();
5455 $ this ->hasGenerated = true ;
5556 }
5657 }
@@ -215,8 +216,8 @@ private function generateSprite() {
215216 ) );
216217 }
217218
218- $ free [ $ i ]['x ' ] = $ free [ $ i ]['x ' ] + $ icon ->width + $ tileMargin ;
219- $ free [ $ i ]['width ' ] = $ free [ $ i ]['width ' ] - $ icon ->width - $ tileMargin ;
219+ $ free [ $ i ]['x ' ] = $ free [ $ i ]['x ' ] + $ icon ->width + $ tileMargin ;
220+ $ free [ $ i ]['width ' ] = $ free [ $ i ]['width ' ] - $ icon ->width - $ tileMargin ;
220221 $ free [ $ i ]['height ' ] = $ icon ->height ;
221222 if ( $ free [ $ i ]['width ' ] <= 0 ) {
222223 array_splice ( $ free , $ i , 1 );
@@ -371,11 +372,14 @@ private function generateCSS() {
371372 private function getChecksum () {
372373 $ content = "" ;
373374
374- foreach ( $ this ->icons as $ icon ) {
375- $ content .= $ icon ->file . file_get_contents ( $ this ->srcDirectory . "/ " . $ icon ->file );
375+ if ( $ this ->spriteChecksum === false ) {
376+ foreach ( $ this ->icons as $ icon ) {
377+ $ content .= $ icon ->file . file_get_contents ( $ this ->srcDirectory . "/ " . $ icon ->file );
378+ }
379+ $ this ->spriteChecksum = sha1 ( $ content );
376380 }
377381
378- return sha1 ( $ content ) ;
382+ return $ this -> spriteChecksum ;
379383 }
380384
381385 private function generateChecksum () {
0 commit comments