Skip to content

Commit f0e0561

Browse files
authored
Merge pull request #9 from rameel/optimize
Optimize ArrayView.Create method for empty collection expression
2 parents feadbea + 5249400 commit f0e0561

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

README.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# Ramstack.Structures
22

3-
Ramstack.Structures is a .NET library providing various data structures and utilities.
3+
[![NuGet](https://img.shields.io/nuget/v/Ramstack.Structures.svg)](https://nuget.org/packages/Ramstack.Structures)
4+
[![MIT](https://img.shields.io/github/license/rameel/ramstack.structures)](https://github.com/rameel/ramstack.structures/blob/main/LICENSE)
45

5-
[![.NET](https://github.com/rameel/ramstack.structures/actions/workflows/test.yml/badge.svg)](https://github.com/rameel/ramstack.structures/actions/workflows/test.yml)
6+
Ramstack.Structures is a .NET library providing various data structures and utilities.
67

78
## Installation
89

@@ -47,14 +48,20 @@ foreach (ref readonly HeavyStruct s in view)
4748
```
4849
## Changelog
4950

51+
### 1.2.2
52+
- Optimize `ArrayView.Create` method for empty collection expression
53+
54+
### 1.2.1
55+
- Add `List<T>` to `ArrayView<T>` extension for NET9.0+
56+
5057
### 1.2.0
5158
- Add `Trim` overloads to `StringView` class
5259

5360
## Supported versions
5461

55-
| | Version |
56-
|------|---------|
57-
| .NET | 6, 7, 8 |
62+
| | Version |
63+
|------|------------|
64+
| .NET | 6, 7, 8, 9 |
5865

5966
## Contributions
6067

Ramstack.Structures/Collections/ArrayView.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ public static ArrayView<T> Create<T>(params T[] items) =>
2929
/// <returns>
3030
/// An <see cref="ArrayView{T}"/> instance for the specified read-only span.
3131
/// </returns>
32-
public static ArrayView<T> Create<T>(ReadOnlySpan<T> items) =>
33-
new(items.ToArray());
32+
public static ArrayView<T> Create<T>(params ReadOnlySpan<T> items) =>
33+
items.Length != 0
34+
? new ArrayView<T>(items.ToArray())
35+
: ArrayView<T>.Empty;
3436
}

0 commit comments

Comments
 (0)