Skip to content

Commit 3586fd9

Browse files
committed
Update docs
1 parent 415f37b commit 3586fd9

File tree

4 files changed

+20
-19
lines changed

4 files changed

+20
-19
lines changed

docs/site/articles/concepts.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
# How does it work?
2-
Before I answer the question, I would like to raise another question: How does it work differently and more effective than the current `StringBuilder`?
2+
Before I answer the question, I would like to raise another question: How does it work differently and more effectively than the current `StringBuilder`?
33

4-
The basic idea is to use a `ref struct` which enforces that the `ValueStringBuilder` will life on the **stack** instead of the **heap**.
5-
Furthermore we try to use advanced features like `Span<T>` and `ArrayPool` to reduce allocations even further. Because of the way C# / .NET is optimized for those types the `ValueStringBuilder` gains a lot of speed with low allocations.
6-
7-
With this approach some limitations arise. Head over to the [known limitation](xref:known_limitations) to know more.
4+
The basic idea is to use a `ref struct` which enforces that the `ValueStringBuilder` will live on the **stack** instead of the **heap**.
5+
Furthermore, we try to use advanced features like `Span<T>` and `ArrayPool` to reduce allocations even further. Because of the way C# / .NET is optimized for those types the `ValueStringBuilder` gains a lot of speed with low allocations.
6+
With this approach, some limitations arise. Head over to the [known limitation](xref:known_limitations) to know more.
87

98
## Resources:
109
[Here](https://steven-giesel.com/blogPost/4cada9a7-c462-4133-ad7f-e8b671987896) is my detailed blog post about some of the implementation details.

docs/site/articles/getting_started.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,10 @@ public static class Program
3232
```
3333

3434
Prints:
35-
36-
> Hello dear World!
37-
0.3
38-
39-
[Here](https://dotnetfiddle.net/wM5r0q) an interactive example where you can fiddle around with the library. The example is hosted on [https://dotnetfiddle.net/](https://dotnetfiddle.net/wM5r0q) and already has the `ValueStringBuilder` nuget package included in the latest version.
35+
[Here](https://dotnetfiddle.net/wM5r0q) is an interactive example where you can fiddle around with the library. The example is hosted on [https://dotnetfiddle.net/](https://dotnetfiddle.net/wM5r0q) and already has the `ValueStringBuilder` nuget package included in the latest version.
4036

4137
## Helper methods
42-
There are also very easy to use helper methods, which doesn't need a `ValueStringBuilder` instance:
38+
There are also very easy-to-use helper methods, which doesn't need a `ValueStringBuilder` instance:
4339
```csharp
4440
using LinkDotNet.StringBuilder;
4541

docs/site/articles/known_limitations.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
uid: known_limitations
33
---
44
# Known Limitations
5-
The base of the `ValueStringBuilder` is a `ref struct`. With that there are certain limitations, which might make it not a good fit for your needs.
5+
The base of the `ValueStringBuilder` is a `ref struct`. With that, there are certain limitations, which might make it not a good fit for your needs.
66
* `ref struct`s can only live on the **stack** and therefore can not be a field for a **class** or a non **ref struct**.
77
* Therefore they can't be boxed to `ValueType` or `Object`.
8-
* Can't be captured ny a lambda expression (aka closure).
8+
* Can't be captured by a lambda expression (aka closure).
99
* Can't be used in `async` methods.
10-
* Can't be used in methods which use the `yield` keyword
10+
* Can't be used in methods that use the `yield`` keyword
1111

12-
If not off this applies to your use case, you are good to go. Using `ref struct` is a trade for performance and less allocations in contrast to its use cases.
12+
If not off this applies to your use case, you are good to go. Using `ref struct` is a trade for performance and fewer allocations in contrast to its use cases.
1313

1414
`ValueStringBuilder` offers the possibility to "convert" it into a "regular" `System.Text.StringBuilder`. Check out the following extension method via the <xref:LinkDotNet.StringBuilder.ValueStringBuilderExtensions>.
1515

@@ -25,4 +25,4 @@ var greeting = stringBuilder
2525
.ToString();
2626
```
2727

28-
This does not work with the `ValueStringBuilder`. The simple reason: `struct`s can't return `return ref this`. If we don't return the reference then new allocations are introduced and can also lead to potential bugs / issues. Therefore it is a conscious design decision not to allow fluent notation.
28+
This does not work with the `ValueStringBuilder`. The simple reason: `struct`s can't return `return ref this`. If we don't return the reference then new allocations are introduced and can also lead to potential bugs/issues. Therefore it is a conscious design decision not to allow fluent notation.

docs/site/index.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44

55
# ValueStringBuilder: A fast and low allocation StringBuilder for .NET
66

7-
**ValueStringBuilder** aims to be as fast as possible with a minimal amount of allocation memory. This documentation will show case you how to use the `ValueStringBuilder` as well as what are some limitations coming with it. If you have questions or feature requests just head over to the [GitHub](https://github.com/linkdotnet/StringBuilder) repository and file and issue.
7+
**ValueStringBuilder** aims to be as fast as possible with a minimal amount of allocation memory. This documentation will showcase to you how to use the `ValueStringBuilder` as well as what are some limitations coming with it. If you have questions or feature requests just head over to the [GitHub](https://github.com/linkdotnet/StringBuilder) repository and file an issue.
88

9-
The library makes heavily use of `Span<T>`, `stackalloc` and `ArrayPool`s to achieve the low allocations and fast performance.
9+
The library makes heavy use of `Span<T>`, `stackalloc` and `ArrayPool`s to achieve low allocations and fast performance.
1010

1111
## Download
1212
The package is hosted on [nuget.org]((https://www.nuget.org/packages/LinkDotNet.StringBuilder/)), so easily add the package reference:
1313
> PM> Install-Package LinkDotNet.StringBuilder
1414
15-
Afterwards you can simply use it. It tries to mimic the API of the `StringBuilder` to a certain extend so for simpler cases you can exchange those two.
15+
Afterwards, you can simply use it. It tries to mimic the API of the `StringBuilder` to a certain extent so for simpler cases you can exchange those two.
1616

1717

1818
## Example usage
@@ -31,4 +31,10 @@ This will print
3131
```
3232
Hello World
3333
2+2=4
34+
```
35+
36+
There are also convenient helper methods like this:
37+
```csharp
38+
_ = ValueStringBuilder.Concat("Hello", " ", "World"); // "Hello World"
39+
_ = ValueStringBuilder.Concat("Hello", 1, 2, 3, "!"); // "Hello123!"
3440
```

0 commit comments

Comments
 (0)