You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Two small but clean performance / code-quality improvements found while looking for allocation hot-spots.
1 β Cache JsonSerializerOptions in AppSettings (avoids repeated construction)
JsonSerializerOptions is explicitly flagged in the .NET docs as expensive to construct because it builds internal converter caches on first use. Previously Load() and Save() each allocated a fresh instance on every call:
// Before β new object every Save() / Load()varjson=JsonSerializer.Serialize(this,newJsonSerializerOptions{WriteIndented=true});
The two option objects are now static readonly fields, so construction happens exactly once per process lifetime.
2 β Extract static LerpColor helper and colour constants
SetColorTemperature and UpdateAdditionalMonitorWindows both defined an identical local Lerp function and the same cool / warmColor literals inline. That means:
The same magic colour values (R220 G235 B255 / R255 G220 B180) existed in two places β a maintenance hazard.
Each call site defined a new local-function object (minor, but avoidable).
They are now a single static helper and two static readonly Color fields.
Backwards Compatibility
No behaviour changes. All logic is identical; only the allocation and definition sites have moved.
Test Status
Built with dotnet build /p:EnableWindowsTargeting=true β 0 errors, 0 warnings.
Full functional testing requires Windows; no automated test suite exists for this WPF app.
Note
π Integrity filter blocked 2 items
The following items were blocked because they don't meet the GitHub integrity level.
#26list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".
gh aw add githubnext/agentics/workflows/repo-assist.md@cbb46ab386962aa371045839fc9998ee4e97ca64
Note
This was originally intended as a pull request, but GitHub Actions is not permitted to create or approve pull requests in this repository.
The changes have been pushed to branch repo-assist/perf-static-json-options-color-lerp-2026-06-10-72c8512de0f82bcf.
To fix the permissions issue, go to Settings β Actions β General and enable Allow GitHub Actions to create and approve pull requests. See also: gh-aw FAQ
Show patch preview (139 of 139 lines)
From 9c754075c251a4c8ef7d4bcbf399eff947db38d0 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]" <github-actions[bot]@users.noreply.github.com>
Date: Wed, 10 Jun 2026 01:36:14 +0000
Subject: [PATCH] Cache JsonSerializerOptions and extract color Lerp helper
JsonSerializerOptions are expensive to construct (they hold internal
converter caches). Previously AppSettings.Load() and AppSettings.Save()
each created a fresh instance on every call. Promoting them to static
readonly fields means the objects are built once and reused.
The Lerp colour helper and the CoolColor/WarmColor constants were
duplicated in two methods (SetColorTemperature and
UpdateAdditionalMonitorWindows). Extract them to static members so
the values are defined in exactly one place, reducing maintenance
risk and eliminating the repeated local-function definitions.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---
WindowsEdgeLight/AppSettings.cs | 23 +++++++++--------
WindowsEdgeLight/MainWindow.xaml.cs | 40 ++++++++++-------------------
2 files changed, 26 insertions(+), 37 deletions(-)
diff --git a/WindowsEdgeLight/AppSettings.cs b/WindowsEdgeLight/AppSettings.cs
index bf12831..3c9a582 100644
--- a/WindowsEdgeLight/AppSettings.cs+++ b/WindowsEdgeLight/AppSettings.cs@@ -20,6 +20,17 @@ public class AppSettings
/// </summary>
public bool ExcludeFromCapture { get; set; } = true;
+ private static readonly JsonSerializerOptions ReadOptions = new JsonSerializerOptions+ {+ AllowTrailingCommas = true,+ ReadCommentHandling = JsonCommentHandling.Skip+ };++ private static readonly JsonSerializerOptions WriteOptions = new JsonSerializerOptions+ {+ WriteIndented = true+ };+
/// <summary>
/// Load settings from disk
/// </summary>
@@ -30,12 +41,7 @@ public class AppSettings
if (File.Exists(SettingsFilePath))
{
var json = File.ReadAllText(SettingsFilePath);
-
... (truncated)
π€ This is an automated PR from Repo Assist.
Summary
Two small but clean performance / code-quality improvements found while looking for allocation hot-spots.
1 β Cache
JsonSerializerOptionsinAppSettings(avoids repeated construction)JsonSerializerOptionsis explicitly flagged in the .NET docs as expensive to construct because it builds internal converter caches on first use. PreviouslyLoad()andSave()each allocated a fresh instance on every call:The two option objects are now
static readonlyfields, so construction happens exactly once per process lifetime.2 β Extract static
LerpColorhelper and colour constantsSetColorTemperatureandUpdateAdditionalMonitorWindowsboth defined an identical localLerpfunction and the samecool/warmColorliterals inline. That means:They are now a single static helper and two
static readonly Colorfields.Backwards Compatibility
No behaviour changes. All logic is identical; only the allocation and definition sites have moved.
Test Status
Built with
dotnet build /p:EnableWindowsTargeting=trueβ 0 errors, 0 warnings.Full functional testing requires Windows; no automated test suite exists for this WPF app.
Note
π Integrity filter blocked 2 items
The following items were blocked because they don't meet the GitHub integrity level.
list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".list_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".To allow these resources, lower
min-integrityin your GitHub frontmatter:Note
This was originally intended as a pull request, but GitHub Actions is not permitted to create or approve pull requests in this repository.
The changes have been pushed to branch
repo-assist/perf-static-json-options-color-lerp-2026-06-10-72c8512de0f82bcf.Click here to create the pull request
To fix the permissions issue, go to Settings β Actions β General and enable Allow GitHub Actions to create and approve pull requests. See also: gh-aw FAQ
Show patch preview (139 of 139 lines)