Skip to content

Commit b37d67a

Browse files
committed
No need to continually generate this static data
1 parent c66b340 commit b37d67a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/Sabberworm/CSS/Parser.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ class Parser {
3232
private $sCharset;
3333
private $iLength;
3434
private $peekCache = null;
35+
private $blockRules;
36+
private $sizeUnits;
3537

3638
public function __construct($sText, Settings $oParserSettings = null) {
3739
$this->sText = $sText;
@@ -40,6 +42,8 @@ public function __construct($sText, Settings $oParserSettings = null) {
4042
$oParserSettings = Settings::create();
4143
}
4244
$this->oParserSettings = $oParserSettings;
45+
$this->blockRules = explode('/', AtRule::BLOCK_RULES);
46+
$this->sizeUnits = explode('/', Size::ABSOLUTE_SIZE_UNITS.'/'.Size::RELATIVE_SIZE_UNITS.'/'.Size::NON_SIZE_UNITS);
4347
}
4448

4549
public function setCharset($sCharset) {
@@ -130,7 +134,7 @@ private function parseAtRule() {
130134
$sArgs = $this->consumeUntil('{', false, true);
131135
$this->consumeWhiteSpace();
132136
$bUseRuleSet = true;
133-
foreach(explode('/', AtRule::BLOCK_RULES) as $sBlockRuleName) {
137+
foreach($this->blockRules as $sBlockRuleName) {
134138
if(self::identifierIs($sIdentifier, $sBlockRuleName)) {
135139
$bUseRuleSet = false;
136140
break;
@@ -393,7 +397,7 @@ private function parseNumericValue($bForColor = false) {
393397
}
394398
$fSize = floatval($sSize);
395399
$sUnit = null;
396-
foreach(explode('/', Size::ABSOLUTE_SIZE_UNITS.'/'.Size::RELATIVE_SIZE_UNITS.'/'.Size::NON_SIZE_UNITS) as $sDefinedUnit) {
400+
foreach($this->sizeUnits as $sDefinedUnit) {
397401
if ($this->comes($sDefinedUnit, true)) {
398402
$sUnit = $sDefinedUnit;
399403
$this->consume($sDefinedUnit);

0 commit comments

Comments
 (0)