File tree Expand file tree Collapse file tree 1 file changed +2
-9
lines changed Expand file tree Collapse file tree 1 file changed +2
-9
lines changed Original file line number Diff line number Diff line change 1616
1717class LanguageData extends LanguageSubset
1818{
19+ private static array $ fileContents = [];
1920 /** @var array<string, array<int, int>> $ngrams */
2021 protected array $ ngrams ;
2122 /** @var array<int, string> $langCodes */
@@ -29,8 +30,6 @@ class LanguageData extends LanguageSubset
2930 /** @var bool $isSubset */
3031 protected $ isSubset ;
3132
32- private static array $ fileContents = [];
33-
3433 public function __construct (?string $ ngramsFile = null )
3534 {
3635 // Opcache needs to be active, so the load of the database array does not add overhead.
@@ -59,13 +58,7 @@ public function __construct(?string $ngramsFile = null)
5958 */
6059 private function loadFileContents (string $ file ): array
6160 {
62- if (isset (self ::$ fileContents [$ file ])) {
63- return self ::$ fileContents [$ file ];
64- }
65-
66- $ data = require_once $ file ;
67-
68- return self ::$ fileContents [$ file ] = $ data ;
61+ return self ::$ fileContents [$ file ] ?? (self ::$ fileContents [$ file ] = require $ file );
6962 }
7063
7164 /*
You can’t perform that action at this time.
0 commit comments