From 6d1c3c2a10d5f0a523f891304bfe87f3101594bf Mon Sep 17 00:00:00 2001 From: Krzysztof Cwalina Date: Wed, 10 Jan 2018 15:16:08 -0800 Subject: [PATCH] Removed Position.Get (#2045) --- .../System/Buffers/Sequences/ReadOnlyBytes.cs | 10 ++++++++++ .../System/Collections/Position.cs | 9 --------- .../SampleCollections/LinkedContainer.cs | 10 ++++++++++ 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/System.Buffers.Experimental/System/Buffers/Sequences/ReadOnlyBytes.cs b/src/System.Buffers.Experimental/System/Buffers/Sequences/ReadOnlyBytes.cs index 9df0294d736..f90b045acd9 100644 --- a/src/System.Buffers.Experimental/System/Buffers/Sequences/ReadOnlyBytes.cs +++ b/src/System.Buffers.Experimental/System/Buffers/Sequences/ReadOnlyBytes.cs @@ -378,6 +378,16 @@ public override string ToString() } } + + public static class PositionExtensions + { + public static (T segment, int index) Get(this Position position) + { + var segment = position.Segment; + var index = position.Index; + return ((T)segment, index); + } + } } diff --git a/src/System.Buffers.Primitives/System/Collections/Position.cs b/src/System.Buffers.Primitives/System/Collections/Position.cs index c98ba36062b..dc152ff3d39 100644 --- a/src/System.Buffers.Primitives/System/Collections/Position.cs +++ b/src/System.Buffers.Primitives/System/Collections/Position.cs @@ -1,9 +1,7 @@ // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System.Buffers; using System.ComponentModel; -using System.Diagnostics; using System.Runtime.CompilerServices; namespace System.Collections.Sequences @@ -30,13 +28,6 @@ public Position(object segment) public static explicit operator int(Position position) => position._index; - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public (T segment, int index) Get() - { - var segment = _segment == null ? default : (T)_segment; - return (segment, _index); - } - public static bool operator ==(Position left, Position right) => left._index == right._index && left._segment == right._segment; public static bool operator !=(Position left, Position right) => left._index != right._index || left._segment != right._segment; diff --git a/tests/System.Collections.Sequences.Tests/SampleCollections/LinkedContainer.cs b/tests/System.Collections.Sequences.Tests/SampleCollections/LinkedContainer.cs index f2bcca2943a..47f9d19ffc7 100644 --- a/tests/System.Collections.Sequences.Tests/SampleCollections/LinkedContainer.cs +++ b/tests/System.Collections.Sequences.Tests/SampleCollections/LinkedContainer.cs @@ -71,4 +71,14 @@ public Position Seek(Position origin, long offset) return new Position(node, 0); } } + + public static class PositionExtensions + { + public static (T segment, int index) Get(this Position position) + { + var segment = position.Segment; + var index = position.Index; + return ((T)segment, index); + } + } }