Havunen / SystemTextJsonPatch

SystemTextJsonPatch is a JSON Patch (JsonPatchDocument) RFC 6902 implementation for .NET using System.Text.Json
MIT License
102 stars 12 forks source link

Use Throw helpers for throwing exceptions #21

Closed jmbryan4 closed 1 year ago

jmbryan4 commented 1 year ago

use the ArgumentNullException.ThrowIfNull throw helper where possible to improve performance. Available with .NET 6

see: https://devblogs.microsoft.com/dotnet/performance_improvements_in_net_7/#exceptions source: https://github.com/dotnet/runtime/blob/main/src/libraries/System.Private.CoreLib/src/System/ArgumentNullException.cs#L67-L69

https://andrewlock.net/exploring-dotnet-6-part-11-callerargumentexpression-and-throw-helpers/#throw-helpers-in-c-

https://github.com/search?q=repo%3AHavunen%2FSystemTextJsonPatch%20throw%20new%20Argument&type=code image

Havunen commented 1 year ago

Hi, thanks for sharing. We should implement this IMO 👍

Havunen commented 1 year ago

This is now implemented in master branch and will be available in the next release. The change improved overall performance about 5%.