TypePHP 编译器 https://swoole.com/aot/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

39 lines
742 B

--TEST--
expected and unexpected provide branch prediction hints without changing condition semantics
--FILE--
<?php
function predicted_condition(int &$calls, bool $result): bool
{
$calls++;
return $result;
}
function main(): void
{
$calls = 0;
if (expected(predicted_condition($calls, true))) {
echo "expected\n";
}
if (unexpected(predicted_condition($calls, false))) {
echo "unexpected-true\n";
} else {
echo "unexpected-false\n";
}
if (\expected(condition: predicted_condition($calls, true))) {
echo "fully-qualified\n";
}
var_dump(expected(1), unexpected(0), $calls);
}
?>
--EXPECT--
expected
unexpected-false
fully-qualified
bool(true)
bool(false)
int(3)