mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 09:56:06 +00:00
Import global functions and constants for enhanced performance
This is better for performance because these then don't need to be reevaluated every time they are called. When encountering an unqualified function or constant reference, PHP will first try to locate a symbol in the current namespace by that name, and then fall back to the global namespace. This short-circuits the check, which has substantial performance effects in some cases - in particular, ord(), chr() and strlen() show ~1500x faster calls when they are fully qualified. However, this doesn't mean that PM is getting a massive amount faster. In real world terms, this translates to about 10-15% performance improvement. But before anyone gets excited, you should know that the CodeOptimizer in the PreProcessor repo has been applying fully-qualified symbol optimizations to Jenkins builds for years, which is one of the reasons why Jenkins builds have better performance than home-built or source installations. We're choosing to do this for the sake of future SafePHP integration and also to be able to get rid of the buggy CodeOptimizer, so that phar and source are more consistent.
This commit is contained in:
@ -24,6 +24,20 @@ declare(strict_types=1);
|
||||
namespace pocketmine\lang;
|
||||
|
||||
use pocketmine\utils\MainLogger;
|
||||
use function array_filter;
|
||||
use function array_map;
|
||||
use function file_exists;
|
||||
use function is_dir;
|
||||
use function ord;
|
||||
use function parse_ini_file;
|
||||
use function scandir;
|
||||
use function str_replace;
|
||||
use function strlen;
|
||||
use function strpos;
|
||||
use function strtolower;
|
||||
use function substr;
|
||||
use const INI_SCANNER_RAW;
|
||||
use const SCANDIR_SORT_NONE;
|
||||
|
||||
class BaseLang{
|
||||
|
||||
@ -93,7 +107,7 @@ class BaseLang{
|
||||
|
||||
protected static function loadLang(string $path, array &$d){
|
||||
if(file_exists($path)){
|
||||
$d = array_map('stripcslashes', parse_ini_file($path, false, INI_SCANNER_RAW));
|
||||
$d = array_map('\stripcslashes', parse_ini_file($path, false, INI_SCANNER_RAW));
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
|
@ -23,6 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\lang;
|
||||
|
||||
use function count;
|
||||
|
||||
class TranslationContainer extends TextContainer{
|
||||
|
||||
/** @var string[] $params */
|
||||
|
Reference in New Issue
Block a user