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
This not the only spot where this is happening and would require a lot of refactoring throughout the code. Using a lamba could probably resolve this issue.
Throw.IfOutOfRange(nameof(x),0, Image.Width -1, x,()=>$"Invalid X coordinate: {x}.");
I don't know when I will have time to work on this. Feel free to open a pull request to change this. Maybe you could use UnsafePixelCollection for now because that class doesn't contain those checks.
I'm not sure a lambda would help as it still needs to capture the parameter, but I might take a look over the weekend to see if I can come up with something :)
Magick.NET version
13.2.0 (Also relevant on main)
Environment (Operating system, version and so on)
Windows
Description
The code here: https://github.com/dlemstra/Magick.NET/blob/main/src/Magick.NET/Pixels/SafePixelCollection.cs#L196
Always allocates the 2 error strings, even if they aren't going to be used due to the interpolation.
Why is this an issue? Mainly because it causes extra work for the GC. If you want to get absolutely crazy, you can use create an interpolated string handler, that can conditionally create the string, as seen here: https://devblogs.microsoft.com/dotnet/string-interpolation-in-c-10-and-net-6/#debug-assert-without-the-overhead
Steps to Reproduce
Call
GetPixel(x, y)
with a memory profiler attached.The text was updated successfully, but these errors were encountered: