Skip to content

Commit 8d041cb

Browse files
committed
Fixed compiler warning
1 parent 2f3c939 commit 8d041cb

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/DotNext/Buffers/SparseBufferWriter.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,10 @@ public void Write(ReadOnlyMemory<T> input, bool copyMemory = true)
169169
{
170170
ObjectDisposedException.ThrowIf(IsDisposed, this);
171171
if (input.IsEmpty)
172-
goto exit;
173-
174-
if (copyMemory)
172+
{
173+
// return, nothing to write
174+
}
175+
else if (copyMemory)
175176
{
176177
Write(input.Span);
177178
}
@@ -185,17 +186,14 @@ public void Write(ReadOnlyMemory<T> input, bool copyMemory = true)
185186
last = new ImportedMemoryChunk(input, last);
186187
length += input.Length;
187188
}
188-
189-
exit:
190-
return;
191189
}
192190

193191
/// <summary>
194192
/// Adds a single item to the buffer.
195193
/// </summary>
196194
/// <param name="item">The item to add.</param>
197195
/// <exception cref="ObjectDisposedException">The builder has been disposed.</exception>
198-
public void Add(T item) => Write(CreateReadOnlySpan(ref item, 1));
196+
public void Add(T item) => Write(new(ref item));
199197

200198
/// <inheritdoc />
201199
void IGrowableBuffer<T>.Write(T value) => Add(value);

0 commit comments

Comments
 (0)