cast to array instead of checking is_assoc

databind
Vitaliy Filippov 2015-04-08 01:44:43 +03:00
parent 5724ef5ba5
commit b1843eba7d
3 changed files with 6 additions and 15 deletions

View File

@ -162,7 +162,7 @@ c_for = for varref/varref "=" exp/exp "-->" chunks/cs "<!--" "END" {
$$ = "\$stack[] = ".$varref[0].";
\$stack[] = ".$varref_index.";
\$stack[] = 0;
foreach (self::array1($exp[0]) as \$item) {
foreach ((array)($exp[0]) as \$item) {
".$varref[0]." = \$item;
".$varref_index." = \$stack[count(\$stack)-1]++;
".$cs."}

View File

@ -4,7 +4,7 @@
* Homepage: http://yourcmc.ru/wiki/VMX::Template
* License: GNU GPLv3 or later
* Author: Vitaliy Filippov, 2006-2015
* Version: V3 (LALR), 2015-03-09
* Version: V3 (LALR), 2015-04-08
*
* This file contains the implementation of VMX::Template compiler.
* It is only used when a template is compiled in runtime.
@ -3761,7 +3761,7 @@ class VMXTemplateParser extends lime_parser {
$result = "\$stack[] = ".$varref[0].";
\$stack[] = ".$varref_index.";
\$stack[] = 0;
foreach (self::array1($exp[0]) as \$item) {
foreach ((array)($exp[0]) as \$item) {
".$varref[0]." = \$item;
".$varref_index." = \$stack[count(\$stack)-1]++;
".$cs."}
@ -4992,5 +4992,5 @@ class VMXTemplateParser extends lime_parser {
);
}
// Time: 2,6265029907227 seconds
// Memory: 11885624 bytes
// Time: 3,1172089576721 seconds
// Memory: 11886108 bytes

View File

@ -8,7 +8,7 @@
* Homepage: http://yourcmc.ru/wiki/VMX::Template
* License: GNU GPLv3 or later
* Author: Vitaliy Filippov, 2006-2015
* Version: V3 (LALR), 2015-03-09
* Version: V3 (LALR), 2015-04-08
*
* The template engine is split into two parts:
* (1) This file - always used when running templates
@ -476,15 +476,6 @@ class VMXTemplate
throw new VMXTemplateException("Unknown block or function '$block'$errorinfo");
}
static function array1($a)
{
if (is_null($a))
return array();
if (is_array($a) && !self::is_assoc($a))
return $a;
return array($a);
}
// No-op, just returns the single argument. Needed to workaround ($expression)['key'] and ($expression)->m() issues.
static function noop($a)
{