From a284bac2756595972a268aff97a20c0c6d7bec9e Mon Sep 17 00:00:00 2001 From: sveinungf Date: Sun, 22 Dec 2024 23:27:33 +0100 Subject: [PATCH] Use string interpolation handler in WorksheetEndXml --- SpreadCheetah/MetadataXml/WorksheetEndXml.cs | 50 ++++---------------- 1 file changed, 9 insertions(+), 41 deletions(-) diff --git a/SpreadCheetah/MetadataXml/WorksheetEndXml.cs b/SpreadCheetah/MetadataXml/WorksheetEndXml.cs index ca2352d..32a473f 100644 --- a/SpreadCheetah/MetadataXml/WorksheetEndXml.cs +++ b/SpreadCheetah/MetadataXml/WorksheetEndXml.cs @@ -1,5 +1,4 @@ using SpreadCheetah.CellReferences; -using SpreadCheetah.Helpers; using SpreadCheetah.Validations; namespace SpreadCheetah.MetadataXml; @@ -87,32 +86,14 @@ public bool MoveNext() private readonly bool TryWriteAutoFilter() { - if (_autoFilterRange is not { } range) return true; - - var span = _buffer.GetSpan(); - var written = 0; - - if (!""u8.TryCopyTo(span, ref written)) return false; - - _buffer.Advance(written); - return true; + return _autoFilterRange is not { } range + || _buffer.TryWrite($"{""u8}"); } private readonly bool TryWriteCellMergesStart() { - if (_cellMerges.IsEmpty) return true; - - var span = _buffer.GetSpan(); - var written = 0; - - if (!""u8.TryCopyTo(span, ref written)) return false; - - _buffer.Advance(written); - return true; + return _cellMerges.IsEmpty + || _buffer.TryWrite($"{""u8}"); } private bool TryWriteCellMerges() @@ -123,14 +104,10 @@ private bool TryWriteCellMerges() for (; _nextIndex < cellMerges.Length; ++_nextIndex) { var cellMerge = cellMerges[_nextIndex]; - var span = _buffer.GetSpan(); - var written = 0; - if (!""u8.TryCopyTo(span, ref written)) return false; - - _buffer.Advance(written); + var success = _buffer.TryWrite($"{""u8}"); + if (!success) + return false; } _nextIndex = 0; @@ -142,17 +119,8 @@ private readonly bool TryWriteCellMergesEnd() private readonly bool TryWriteValidationsStart() { - if (_validations.IsEmpty) return true; - - var span = _buffer.GetSpan(); - var written = 0; - - if (!""u8.TryCopyTo(span, ref written)) return false; - - _buffer.Advance(written); - return true; + return _validations.IsEmpty + || _buffer.TryWrite($"{""u8}"); } private bool TryWriteValidations()