Skip to content

Commit 46a2703

Browse files
committed
refactor: use new Paths() instead of config()
`new Paths()` is faster than config(), and Paths is immutable.
1 parent 017cdbd commit 46a2703

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

app/Config/Paths.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
* share a system folder between multiple applications, and more.
1313
*
1414
* All paths are relative to the project's root folder.
15+
*
16+
* @immutable
1517
*/
1618
class Paths
1719
{

system/Config/Services.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ public static function parser(?string $viewPath = null, ?ViewConfig $config = nu
461461
return static::getSharedInstance('parser', $viewPath, $config);
462462
}
463463

464-
$viewPath = $viewPath ?: config(Paths::class)->viewDirectory;
464+
$viewPath = $viewPath ?: (new Paths())->viewDirectory;
465465
$config ??= config(ViewConfig::class);
466466

467467
return new Parser($config, $viewPath, AppServices::locator(), CI_DEBUG, AppServices::logger());
@@ -480,7 +480,7 @@ public static function renderer(?string $viewPath = null, ?ViewConfig $config =
480480
return static::getSharedInstance('renderer', $viewPath, $config);
481481
}
482482

483-
$viewPath = $viewPath ?: config(Paths::class)->viewDirectory;
483+
$viewPath = $viewPath ?: (new Paths())->viewDirectory;
484484
$config ??= config(ViewConfig::class);
485485

486486
return new View($config, $viewPath, AppServices::locator(), CI_DEBUG, AppServices::logger());

0 commit comments

Comments
 (0)