mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-09 11:44:10 +09:00
Cache opcache status to reduce function_exists() calls
This commit is contained in:
parent
b25ce87ae5
commit
0023a9cc1a
1 changed files with 25 additions and 4 deletions
|
|
@ -17,6 +17,11 @@ class Storage
|
|||
*/
|
||||
protected static $_umask;
|
||||
|
||||
/**
|
||||
* Cache the opcache status here.
|
||||
*/
|
||||
protected static $_opcache;
|
||||
|
||||
/**
|
||||
* Check if a path really exists.
|
||||
*
|
||||
|
|
@ -297,7 +302,11 @@ class Storage
|
|||
$filename = $original_filename;
|
||||
}
|
||||
|
||||
if (function_exists('opcache_invalidate') && substr($filename, -4) === '.php')
|
||||
if (self::$_opcache === null)
|
||||
{
|
||||
self::$_opcache = function_exists('opcache_invalidate');
|
||||
}
|
||||
if (self::$_opcache && substr($filename, -4) === '.php')
|
||||
{
|
||||
@opcache_invalidate($filename, true);
|
||||
}
|
||||
|
|
@ -410,7 +419,11 @@ class Storage
|
|||
$destination = $original_destination;
|
||||
}
|
||||
|
||||
if (function_exists('opcache_invalidate') && substr($destination, -4) === '.php')
|
||||
if (self::$_opcache === null)
|
||||
{
|
||||
self::$_opcache = function_exists('opcache_invalidate');
|
||||
}
|
||||
if (self::$_opcache && substr($destination, -4) === '.php')
|
||||
{
|
||||
@opcache_invalidate($destination, true);
|
||||
}
|
||||
|
|
@ -461,7 +474,11 @@ class Storage
|
|||
@chmod($destination, 0666 & ~self::getUmask());
|
||||
}
|
||||
|
||||
if (function_exists('opcache_invalidate'))
|
||||
if (self::$_opcache === null)
|
||||
{
|
||||
self::$_opcache = function_exists('opcache_invalidate');
|
||||
}
|
||||
if (self::$_opcache)
|
||||
{
|
||||
if (substr($source, -4) === '.php')
|
||||
{
|
||||
|
|
@ -500,7 +517,11 @@ class Storage
|
|||
trigger_error('Cannot delete file: ' . $filename, \E_USER_WARNING);
|
||||
}
|
||||
|
||||
if (function_exists('opcache_invalidate') && substr($filename, -4) === '.php')
|
||||
if (self::$_opcache === null)
|
||||
{
|
||||
self::$_opcache = function_exists('opcache_invalidate');
|
||||
}
|
||||
if (self::$_opcache && substr($filename, -4) === '.php')
|
||||
{
|
||||
@opcache_invalidate($filename, true);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue