From e4b8b0f6aaac28f881c18f0ea5e1f27282a29d08 Mon Sep 17 00:00:00 2001 From: the_hasanov Date: Tue, 23 Oct 2018 17:31:39 +0400 Subject: [PATCH] optimize file find proccess --- src/OpcacheClass.php | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/OpcacheClass.php b/src/OpcacheClass.php index 7307901..fe960a6 100755 --- a/src/OpcacheClass.php +++ b/src/OpcacheClass.php @@ -2,7 +2,7 @@ namespace Appstract\Opcache; -use Illuminate\Support\Facades\File; +use Symfony\Component\Finder\Finder; /** * Class OpcacheClass. @@ -75,23 +75,18 @@ public function optimize() } // Get files in these paths - $files = File::allFiles(config('opcache.directories')); + $files = Finder::create()->in(config('opcache.directories')) + ->name('*.php') + ->files(); $files = collect($files); - // filter on php extension - $files = $files->filter(function ($value) { - return File::extension($value) == 'php'; - }); - // optimized files $optimized = 0; $files->each(function ($file) use (&$optimized) { - if (! opcache_is_script_cached($file)) { - if (@opcache_compile_file($file)) { - $optimized++; - } + if (!opcache_is_script_cached($file) && @opcache_compile_file($file)) { + $optimized++; } });