Skip to content

Commit

Permalink
refs #578 peephole optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
robocoder committed Jul 22, 2018
1 parent 79f6252 commit 1d656f8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Compiler.php
Expand Up @@ -5004,15 +5004,19 @@ protected function libMapMerge($args)
$map2 = $this->assertMap($args[1]);

foreach ($map2[1] as $i2 => $key2) {
$key = $this->compileStringContent($this->coerceString($key2));

foreach ($map1[1] as $i1 => $key1) {
if ($this->compileStringContent($this->coerceString($key1)) === $this->compileStringContent($this->coerceString($key2))) {
if ($key === $this->compileStringContent($this->coerceString($key1))) {
$map1[2][$i1] = $map2[2][$i2];
continue 2;
}
}

$map1[1][] = $map2[1][$i2];
$map1[2][] = $map2[2][$i2];
}

return $map1;
}

Expand Down

0 comments on commit 1d656f8

Please sign in to comment.