Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions QuickShell.Core/Services/PathExecutableLookup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,20 @@
}

var name = Path.GetFileName(fileName.Trim());
foreach (var segment in pathValue.Split(';', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries))
// Performance optimization - avoid string[] and intermediate string allocations
// from pathValue.Split() on long PATH variables. Using AsSpan().Split() with Range
// makes this hot-path executable resolution allocation-free for the segment iteration.
foreach (var range in pathValue.AsSpan().Split(';'))

Check warning

Code scanning / CodeQL

Useless assignment to local variable Warning

This assignment to
range
is useless, since its value is never read.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jules can you commit a change addressing this

{
var segment = pathValue.AsSpan()[range].Trim();
if (segment.IsEmpty)
{
continue;
}

try
{
var candidate = Path.Join(segment, name);
var candidate = Path.Join(segment, name.AsSpan());
if (!File.Exists(candidate))
{
continue;
Expand Down
Loading