Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

Commit

Permalink
Removed Position.Get (#2045)
Browse files Browse the repository at this point in the history
  • Loading branch information
KrzysztofCwalina authored Jan 10, 2018
1 parent ebece56 commit 6d1c3c2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,16 @@ public override string ToString()

}
}

public static class PositionExtensions
{
public static (T segment, int index) Get<T>(this Position position)
{
var segment = position.Segment;
var index = position.Index;
return ((T)segment, index);
}
}
}


9 changes: 0 additions & 9 deletions src/System.Buffers.Primitives/System/Collections/Position.cs
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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<T>()
{
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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<T>(this Position position)
{
var segment = position.Segment;
var index = position.Index;
return ((T)segment, index);
}
}
}

0 comments on commit 6d1c3c2

Please sign in to comment.