4 ms·
Few tips to improve C# performance: - enable source generation for JSON serialization https://learn.microsoft.com/en-us/dotnet/standard/serialization/system-t
by zigzag312 4y ago
Few tips to improve C# performance:
- enable source generation for JSON serialization
https://learn.microsoft.com/en-us/dotnet/standard/serialization/system-text-json/source-generation?pivots=dotnet-6-0#source-generation-support-in-aspnet-core https://learn.microsoft.com/en-us/dotnet/standard/serializat...
- use `TryGetValue` to do single dictionary lookup instead of two.
if (TripsIxByRoute.TryGetValue(route, out var tripIxs))
- specify List's capacity, if it's known when creating it, to avoid resizing operations while adding elements to the List
var schedules = new List<StopTimeResponse>(stopTimeIxs.Count);