fix: switch from explode to substr (faster)

Signed-off-by: Josh Richards <josh.t.richards@gmail.com>
This commit is contained in:
Josh Richards 2024-06-27 10:57:14 -04:00 committed by backportbot[bot]
parent a7b4808b32
commit 344c9682de

View file

@ -228,9 +228,10 @@ class Config {
// grab any "NC_" environment variables
$envRaw = getenv();
// only save environment variables prefixed with "NC_" in the cache
$envPrefixLen = strlen(self::ENV_PREFIX);
foreach ($envRaw as $rawEnvKey => $rawEnvValue) {
if (str_starts_with($rawEnvKey, self::ENV_PREFIX)) {
$realKey = explode(self::ENV_PREFIX, $rawEnvKey)[1];
$realKey = substr($rawEnvKey, $envPrefixLen);
$this->envCache[$realKey] = $rawEnvValue;
}
}