diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2019-07-01 16:25:28 +0200 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2019-07-01 17:27:42 +0200 |
commit | 59522c5a85d0f87679dce05f5a0247deb59e1ba3 (patch) | |
tree | cd7549711c863fdb0c644b709b5e07f19cae26ad | |
parent | 7acc828abff54296d7068d6ae5024bbf0190b2b3 (diff) | |
download | php-git-59522c5a85d0f87679dce05f5a0247deb59e1ba3.tar.gz |
Generate less code in compile time binary op test
Don't generate try {} blocks for the operations that don't throw.
-rw-r--r-- | Zend/tests/runtime_compile_time_binary_operands.phpt | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/Zend/tests/runtime_compile_time_binary_operands.phpt b/Zend/tests/runtime_compile_time_binary_operands.phpt index 897ce3e1a5..afced7af0c 100644 --- a/Zend/tests/runtime_compile_time_binary_operands.phpt +++ b/Zend/tests/runtime_compile_time_binary_operands.phpt @@ -108,16 +108,16 @@ function prepareLine($op1, $op2, $cmp, $operator) { $error = "echo '" . addcslashes("$op1_p $operator $op2_p", "\\'") . '\', "\n"; $f++;'; $compare = "@($op1_p $operator $op2_p)"; - $line = "\$c++; try { "; + $line = "\$c++; "; try { $result = makeParam($cmp()); - $line .= "if (" . ($result === "(NAN)" ? "!is_nan($compare)" : "$compare !== $result") . ") { $error } } catch (Error \$e) { $error }"; + $line .= "if (" . ($result === "(NAN)" ? "!is_nan($compare)" : "$compare !== $result") . ") { $error }"; } catch (Error $e) { if (get_class($e) == "Error") { return "// exempt $op1_p $operator $op2_p from checking, it generates a compile time error"; } $msg = makeParam($e->getMessage()); - $line .= "$compare; $error } catch (Error \$e) { if (\$e->getMessage() !== $msg) { $error } }"; + $line .= "try { $compare; $error } catch (Error \$e) { if (\$e->getMessage() !== $msg) { $error } }"; } return $line; } @@ -130,7 +130,10 @@ fwrite($file, "<?php\n"); foreach ($input as $left) { foreach ($input as $right) { foreach ($operands as $operand) { - fwrite($file, prepareLine($left, $right, function() use ($left, $right, $operand) { return eval("return @(\$left $operand \$right);"); }, $operand) . "\n"); + $line = prepareLine($left, $right, function() use ($left, $right, $operand) { + return eval("return @(\$left $operand \$right);"); + }, $operand); + fwrite($file, $line . "\n"); } } } |