From 8841fd935a7baa35cc12f38c9b4c79a87c9c7925 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 24 Jul 2026 07:21:11 +0000 Subject: [PATCH 1/3] =?UTF-8?q?=E2=9A=A1=20Bolt:=20optimize=20PATH=20split?= =?UTF-8?q?ting=20allocation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replaced string.Split() with AsSpan().Split() in PathExecutableLookup.TryFindOnPath to avoid allocating string arrays and intermediate strings when parsing the PATH environment variable on hot paths. --- QuickShell.Core/Services/PathExecutableLookup.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/QuickShell.Core/Services/PathExecutableLookup.cs b/QuickShell.Core/Services/PathExecutableLookup.cs index be5d483e..314cee50 100644 --- a/QuickShell.Core/Services/PathExecutableLookup.cs +++ b/QuickShell.Core/Services/PathExecutableLookup.cs @@ -115,11 +115,20 @@ public static bool TryFindOnPath(string fileName, out string fullPath) } 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(';')) { + 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; From ac7576ce843c8dbc44f0c040bf06d1fbe76448eb Mon Sep 17 00:00:00 2001 From: "coderabbitai[bot]" <136622811+coderabbitai[bot]@users.noreply.github.com> Date: Sat, 25 Jul 2026 07:45:02 +0000 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=93=9D=20Add=20docstrings=20to=20`bol?= =?UTF-8?q?t-optimize-path-split-292288705065865692`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Docstrings generation was requested by @tonythethompson. The following files were modified: * `QuickShell.Core/Services/PathExecutableLookup.cs` --- QuickShell.Core/Services/PathExecutableLookup.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/QuickShell.Core/Services/PathExecutableLookup.cs b/QuickShell.Core/Services/PathExecutableLookup.cs index 314cee50..f1e00354 100644 --- a/QuickShell.Core/Services/PathExecutableLookup.cs +++ b/QuickShell.Core/Services/PathExecutableLookup.cs @@ -100,6 +100,12 @@ private static IEnumerable EnumerateKnownLocationCandidates(string syste } } + /// + /// Searches the system PATH for an executable file. + /// + /// The executable file name or path to search for. + /// The resolved full path when the executable is found; otherwise, an empty string. + /// if the executable is found on the PATH; otherwise. public static bool TryFindOnPath(string fileName, out string fullPath) { fullPath = string.Empty; From 02a3e1015cb7d36d2567baa0ea05b100d92f6519 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sat, 25 Jul 2026 07:50:40 +0000 Subject: [PATCH 3/3] =?UTF-8?q?=E2=9A=A1=20Bolt:=20optimize=20PATH=20split?= =?UTF-8?q?ting=20allocation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replaced string.Split() with AsSpan().Split() in PathExecutableLookup.TryFindOnPath to avoid allocating string arrays and intermediate strings when parsing the PATH environment variable on hot paths. --- QuickShell.Core/Services/PathExecutableLookup.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/QuickShell.Core/Services/PathExecutableLookup.cs b/QuickShell.Core/Services/PathExecutableLookup.cs index f1e00354..314cee50 100644 --- a/QuickShell.Core/Services/PathExecutableLookup.cs +++ b/QuickShell.Core/Services/PathExecutableLookup.cs @@ -100,12 +100,6 @@ private static IEnumerable EnumerateKnownLocationCandidates(string syste } } - /// - /// Searches the system PATH for an executable file. - /// - /// The executable file name or path to search for. - /// The resolved full path when the executable is found; otherwise, an empty string. - /// if the executable is found on the PATH; otherwise. public static bool TryFindOnPath(string fileName, out string fullPath) { fullPath = string.Empty;