mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-15 11:56:50 +00:00
regex optimization
This commit is contained in:
+2
-2
@@ -41,7 +41,7 @@ class Twig_Lexer implements Twig_LexerInterface
|
|||||||
const REGEX_NUMBER = '/[0-9]+(?:\.[0-9]+)?/A';
|
const REGEX_NUMBER = '/[0-9]+(?:\.[0-9]+)?/A';
|
||||||
const REGEX_STRING = '/\'([^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\'/As';
|
const REGEX_STRING = '/\'([^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\'/As';
|
||||||
const REGEX_DQ_STRING_START = '/"/A';
|
const REGEX_DQ_STRING_START = '/"/A';
|
||||||
const REGEX_DQ_STRING_PART = '/(?:[^#"\\\\]|\\\\.|#(?!{))+/A';
|
const REGEX_DQ_STRING_PART = '/[^#"\\\\]*(?:(?:\\\\.|#(?!\{))[^#"\\\\]*)*/As';
|
||||||
const PUNCTUATION = '()[]{}?:.,|';
|
const PUNCTUATION = '()[]{}?:.,|';
|
||||||
|
|
||||||
public function __construct(Twig_Environment $env, array $options = array())
|
public function __construct(Twig_Environment $env, array $options = array())
|
||||||
@@ -304,7 +304,7 @@ class Twig_Lexer implements Twig_LexerInterface
|
|||||||
$this->moveCursor($match[0]);
|
$this->moveCursor($match[0]);
|
||||||
$this->pushState(self::STATE_INTERPOLATION);
|
$this->pushState(self::STATE_INTERPOLATION);
|
||||||
|
|
||||||
} else if (preg_match(self::REGEX_DQ_STRING_PART, $this->code, $match, null, $this->cursor)) {
|
} else if (preg_match(self::REGEX_DQ_STRING_PART, $this->code, $match, null, $this->cursor) && strlen($match[0]) > 0) {
|
||||||
$this->pushToken(Twig_Token::STRING_TYPE, stripcslashes($match[0]));
|
$this->pushToken(Twig_Token::STRING_TYPE, stripcslashes($match[0]));
|
||||||
$this->moveCursor($match[0]);
|
$this->moveCursor($match[0]);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user