Skip to content

⚡ Optimize JSON property lookup using TryGetProperty in HardwareEndpoints - #70

Merged
spelech merged 1 commit into
mainfrom
perf-optimize-hardware-json-lookup
Sep 20, 2026
Merged

spelech merged 1 commit into
mainfrom
perf-optimize-hardware-json-lookup

Conversation

@spelech

@spelech spelech commented Sep 20, 2026

Copy link
Copy Markdown
Owner

Summary

Addresses failed Jules session \17790085110777310707.

💡 What

  • Replaced repeated
    oot.EnumerateObject()\ linear scans across \GetString, \GetLong, \GetInt, and \GetDouble\ helper methods in \Endpoints/HardwareEndpoints.cs\ with an optimized \TryFindProperty\ routine.
  • \TryFindProperty\ first uses
    oot.TryGetProperty\ for fast (1)$ exact-cased lookups for requested parameter names.
  • Retains case-insensitive property matching as a fallback for backwards compatibility.
  • Added comprehensive unit test in \HardwareEndpointsTests\ verifying property lookup with alternative names and varied casing.

🎯 Why

  • Previously, extracting each property triggered an (N)$ traversal over all object properties.
  • With ~15 properties parsed per request on /api/hardware/evaluate, this created redundant enumeration and enumerator allocation overhead.
  • Using \TryGetProperty\ directly evaluates the property hash in (1)$ time.

@spelech
spelech merged commit 18af805 into main Sep 20, 2026
2 checks passed
@spelech
spelech deleted the perf-optimize-hardware-json-lookup branch September 20, 2026 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant