From 80972e5f5b287809caeabe0b8873c845061f7c34 Mon Sep 17 00:00:00 2001 From: Sergey Mikolaitis Date: Sat, 7 Jan 2023 05:23:58 +0300 Subject: [PATCH] [Text] a bit better usage of Codepoint.ReadAt --- src/Avalonia.Base/Media/TextFormatting/Unicode/Codepoint.cs | 2 +- .../Media/TextFormatting/Unicode/CodepointEnumerator.cs | 2 +- .../Media/TextFormatting/Unicode/GraphemeEnumerator.cs | 2 +- tests/Avalonia.UnitTests/MockTextShaperImpl.cs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Avalonia.Base/Media/TextFormatting/Unicode/Codepoint.cs b/src/Avalonia.Base/Media/TextFormatting/Unicode/Codepoint.cs index ecd0681e15..8b9d1c1d02 100644 --- a/src/Avalonia.Base/Media/TextFormatting/Unicode/Codepoint.cs +++ b/src/Avalonia.Base/Media/TextFormatting/Unicode/Codepoint.cs @@ -231,7 +231,7 @@ namespace Avalonia.Media.TextFormatting.Unicode /// The index to read at. /// The count of character that were read. /// - public static Codepoint ReadAt(ReadOnlySpan text, int index, out int count) + public static Codepoint ReadAt(CharacterBufferRange text, int index, out int count) { count = 1; diff --git a/src/Avalonia.Base/Media/TextFormatting/Unicode/CodepointEnumerator.cs b/src/Avalonia.Base/Media/TextFormatting/Unicode/CodepointEnumerator.cs index a2e29812d3..a2c36d9a13 100644 --- a/src/Avalonia.Base/Media/TextFormatting/Unicode/CodepointEnumerator.cs +++ b/src/Avalonia.Base/Media/TextFormatting/Unicode/CodepointEnumerator.cs @@ -30,7 +30,7 @@ namespace Avalonia.Media.TextFormatting.Unicode return false; } - Current = Codepoint.ReadAt(_text.Span, 0, out var count); + Current = Codepoint.ReadAt(_text, 0, out var count); _text = _text.Skip(count); diff --git a/src/Avalonia.Base/Media/TextFormatting/Unicode/GraphemeEnumerator.cs b/src/Avalonia.Base/Media/TextFormatting/Unicode/GraphemeEnumerator.cs index 2488b620e7..dc21e06813 100644 --- a/src/Avalonia.Base/Media/TextFormatting/Unicode/GraphemeEnumerator.cs +++ b/src/Avalonia.Base/Media/TextFormatting/Unicode/GraphemeEnumerator.cs @@ -245,7 +245,7 @@ namespace Avalonia.Media.TextFormatting.Unicode if (CurrentCodeUnitOffset < _buffer.Length) { - CurrentCodepoint = Codepoint.ReadAt(_buffer.Span, CurrentCodeUnitOffset, + CurrentCodepoint = Codepoint.ReadAt(_buffer, CurrentCodeUnitOffset, out _codeUnitLengthOfCurrentScalar); } else diff --git a/tests/Avalonia.UnitTests/MockTextShaperImpl.cs b/tests/Avalonia.UnitTests/MockTextShaperImpl.cs index d010f9ebf2..00bcef295a 100644 --- a/tests/Avalonia.UnitTests/MockTextShaperImpl.cs +++ b/tests/Avalonia.UnitTests/MockTextShaperImpl.cs @@ -18,7 +18,7 @@ namespace Avalonia.UnitTests { var glyphCluster = i + text.OffsetToFirstChar; - var codepoint = Codepoint.ReadAt(characterBufferRange.Span, i, out var count); + var codepoint = Codepoint.ReadAt(characterBufferRange, i, out var count); var glyphIndex = typeface.GetGlyph(codepoint);