From 1222399c08265a08f9dc71cff41734dfe3c9c22a Mon Sep 17 00:00:00 2001 From: lindexi Date: Mon, 25 Nov 2024 18:45:16 +0800 Subject: [PATCH] Optimize SKRoundRectCache Clear Method for .NET 6+ (#17605) This changes optimizes the `Clear` method in `SKRoundRectCache`. For .NET 6 and higher versions, a faster clearing technique is utilized, enhancing performance. --- src/Skia/Avalonia.Skia/SKRoundRectCache.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Skia/Avalonia.Skia/SKRoundRectCache.cs b/src/Skia/Avalonia.Skia/SKRoundRectCache.cs index 4be6171a93..b84c61303d 100644 --- a/src/Skia/Avalonia.Skia/SKRoundRectCache.cs +++ b/src/Skia/Avalonia.Skia/SKRoundRectCache.cs @@ -91,9 +91,13 @@ namespace Avalonia.Skia base.Clear(); // Clear out the cache of SKPoint arrays. +#if NET6_0_OR_GREATER + _radiiCache.Clear(); +#else while (_radiiCache.TryTake(out var item)) { } +#endif } } }