From e5c40d02d9c5d287337e9ca316c76725deaf1a63 Mon Sep 17 00:00:00 2001 From: jk Date: Tue, 13 Oct 2015 22:39:39 +0200 Subject: [PATCH] quick check to needsCompile for changed registeredVars with a crc32 hash --- src/Compiler.php | 12 ++++++++++++ src/Server.php | 6 ++++++ 2 files changed, 18 insertions(+) diff --git a/src/Compiler.php b/src/Compiler.php index ca6df8fb..d14e0875 100644 --- a/src/Compiler.php +++ b/src/Compiler.php @@ -2701,6 +2701,18 @@ public function unsetVariable($name) unset($this->registeredVars[$name]); } + /** + * Returns list of variables + * + * @api + * + * @return array + */ + public function getVariables() + { + return $this->registeredVars; + } + /** * Adds to list of parsed files * diff --git a/src/Server.php b/src/Server.php index d85a9190..6b2a7003 100644 --- a/src/Server.php +++ b/src/Server.php @@ -143,6 +143,11 @@ protected function needsCompile($in, $out, &$etag) return true; } } + + $metaVars = crc32(serialize($this->scss->getVariables())); + if ($metaVars!=$metadata['vars']) { + return true; + } $etag = $metadata['etag']; @@ -213,6 +218,7 @@ protected function compile($in, $out) serialize(array( 'etag' => $etag, 'imports' => $this->scss->getParsedFiles(), + 'vars' => crc32(serialize($this->scss->getVariables())), )) );