Skip to content

Commit e5d1d9f

Browse files
author
Petr Sramek
committed
updated code to not use ref readonly
1 parent 74d7540 commit e5d1d9f

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

src/PolylineAlgorithm/Internal/PolylineWriter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ internal ref struct PolylineWriter {
2121
/// Initializes a new instance of the <see cref="PolylineWriter"/> struct with the specified buffer.
2222
/// </summary>
2323
/// <param name="buffer">The buffer to write to.</param>
24-
public PolylineWriter(ref readonly Memory<char> buffer) {
24+
public PolylineWriter(Memory<char> buffer) {
2525
_buffer = buffer;
2626
}
2727

@@ -42,7 +42,7 @@ public PolylineWriter(ref readonly Memory<char> buffer) {
4242
/// <exception cref="InvalidCoordinateException">Thrown when the coordinate is invalid.</exception>
4343
/// <exception cref="InvalidWriterStateException">Thrown when the writer is in an invalid state.</exception>
4444
[MethodImpl(MethodImplOptions.AggressiveInlining)]
45-
public void Write(ref readonly Coordinate coordinate) {
45+
public void Write(Coordinate coordinate) {
4646
InvalidCoordinateException.ThrowIfNotValid(coordinate);
4747
InvalidWriterStateException.ThrowIfCannotWrite(CanWrite, Position, _buffer.Length);
4848

src/PolylineAlgorithm/PolylineEncoder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ public Polyline Encode(IEnumerable<Coordinate> coordinates) {
3636

3737
int capacity = count * 12;
3838
Memory<char> buffer = new char[capacity];
39-
PolylineWriter writer = new(in buffer);
39+
PolylineWriter writer = new(buffer);
4040

4141
foreach (var coordinate in coordinates) {
4242
InvalidCoordinateException.ThrowIfNotValid(coordinate);
43-
writer.Write(in coordinate);
43+
writer.Write(coordinate);
4444
}
4545

4646
return writer.ToPolyline();

tests/PolylineAlgorithm.Tests/Internal/PolylineWriterTest.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public void Constructor_Valid_Parameter_Ok(int length) {
6666
int position = 0;
6767

6868
// Act
69-
PolylineWriter writer = new(in buffer);
69+
PolylineWriter writer = new(buffer);
7070

7171
// Assert
7272
Assert.AreEqual(canWrite, writer.CanWrite);
@@ -82,13 +82,13 @@ public void Write_Valid_Parameter_Ok() {
8282
IEnumerable<Coordinate> coordinates = Values.Coordinates.Valid;
8383
Polyline expected = Polyline.FromString(Values.Polyline.Valid);
8484
Memory<char> buffer = new char[coordinates.Count() * 12];
85-
PolylineWriter writer = new(in buffer);
85+
PolylineWriter writer = new(buffer);
8686
bool canWrite = buffer.Length > expected.Length;
8787
int position = expected.Length;
8888

8989
// Act
9090
foreach (var coordinate in coordinates) {
91-
writer.Write(in coordinate);
91+
writer.Write(coordinate);
9292
}
9393

9494
// Assert
@@ -111,8 +111,8 @@ public void Write_Invalid_Coordinate_Parameter_Ok((double Latitude, double Longi
111111
// Act
112112
static void Write(Coordinate coordinate, int bufferSize) {
113113
Memory<char> buffer = new char[bufferSize];
114-
PolylineWriter writer = new(in buffer);
115-
writer.Write(in coordinate);
114+
PolylineWriter writer = new(buffer);
115+
writer.Write(coordinate);
116116
}
117117

118118
// Assert
@@ -132,10 +132,10 @@ public void Write_Buffer_Overflow_InvalidWriterStateException_Thrown(int bufferS
132132
// Act
133133
static void Write(Coordinate coordinate, int bufferSize) {
134134
Memory<char> buffer = new char[bufferSize];
135-
PolylineWriter writer = new(in buffer);
135+
PolylineWriter writer = new(buffer);
136136

137-
writer.Write(in coordinate);
138-
writer.Write(in coordinate);
137+
writer.Write(coordinate);
138+
writer.Write(coordinate);
139139
}
140140

141141
// Assert

0 commit comments

Comments
 (0)