From ef5c9441b66e15a45c993243540ceb0a8b45386a Mon Sep 17 00:00:00 2001 From: h3xds1nz Date: Tue, 20 May 2025 23:06:29 +0200 Subject: [PATCH] Use StrongBox over object field --- .../PresentationCore/System/Windows/Media/GlyphRun.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/GlyphRun.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/GlyphRun.cs index 8bd52d41a38..afb91e07e95 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/GlyphRun.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/GlyphRun.cs @@ -15,6 +15,7 @@ using System.Collections; using System.ComponentModel; +using System.Runtime.CompilerServices; using System.Windows.Media.Converters; using System.Windows.Media.Composition; using System.Windows.Media.TextFormatting; @@ -1226,9 +1227,9 @@ public Rect ComputeInkBoundingBox() if ((_flags & GlyphRunFlags.CacheInkBounds) != 0) { - if (_inkBoundingBox != null) + if (_inkBoundingBox is not null) { - return (Rect)_inkBoundingBox; + return _inkBoundingBox.Value; } } @@ -1401,7 +1402,7 @@ public Rect ComputeInkBoundingBox() if ((_flags & GlyphRunFlags.CacheInkBounds) != 0) { - _inkBoundingBox = bounds; + _inkBoundingBox = new StrongBox(bounds); } return bounds; @@ -2463,7 +2464,7 @@ private enum GlyphRunFlags : byte private IList _caretStops; private XmlLanguage _language; private string _deviceFontName; - private object _inkBoundingBox; // Used when CacheInkBounds is on + private StrongBox _inkBoundingBox; // Used when CacheInkBounds is on private TextFormattingMode _textFormattingMode; private float _pixelsPerDip = MS.Internal.FontCache.Util.PixelsPerDip;