Bug Description
EnvironmentVariableParser.Parse() allocates a List<EnvironmentVariable> before the null/empty input check. Moving the guard clause first avoids the unnecessary allocation on empty input.
Actual Behavior
// EnvironmentVariableParser.cs lines 19-24
var result = new List<EnvironmentVariable>();
if (string.IsNullOrEmpty(input))
return result;
The list is allocated even when input is null or empty.
Suggested Fix
if (string.IsNullOrEmpty(input))
return new List<EnvironmentVariable>();
var result = new List<EnvironmentVariable>();
Or with modern C# collection expressions:
if (string.IsNullOrEmpty(input))
return [];
Environment
- File:
src/Servy.Core/EnvironmentVariables/EnvironmentVariableParser.cs
- Lines: 19-24
Bug Description
EnvironmentVariableParser.Parse()allocates aList<EnvironmentVariable>before the null/empty input check. Moving the guard clause first avoids the unnecessary allocation on empty input.Actual Behavior
The list is allocated even when input is null or empty.
Suggested Fix
Or with modern C# collection expressions:
Environment
src/Servy.Core/EnvironmentVariables/EnvironmentVariableParser.cs