Skip to content

Commit

Permalink
Extended documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
linkdotnet committed Apr 9, 2022
1 parent 4bfd5e7 commit 4aed915
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Install the package:
Afterwards use the package as follow:
```csharp
using LinkDotNet.StringBuilder; // Namespace of the package
ValueStringBuilder stringBuilder = new ValueStringBuilder();
stringBuilder.AppendLine("Hello World");

Expand Down
4 changes: 3 additions & 1 deletion docs/site/articles/comparison.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ uid: comparison

# Comparison

The following document will show some key differences between the `ValueStringBuilder` and similar working string builder like the one from .NET itself.
The following document will show some key differences between the `ValueStringBuilder` and similar working string builder like the one from .NET itself or the famous `ZString` package, which is also free and open-source.

## System.Text.StringBuilder

Expand All @@ -14,6 +14,7 @@ The `StringBuilder` shipped with the .NET Framework itself is a all-purpose stri
- `StringBuilder` is a class and does not have the restrictions coming with a `ref struct`. To know more head over to the [known limitations](xref:known_limitations) section.
- `StringBuilder` works not on `Span<T>` but more on `string`s or `char`s. Sometimes even with pointers
- `StringBuilder` uses chunks to represent the string, which the larger the string gets, the better it can perform. `ValueStringBuilder` only has one internal `Span` as representation which can cause fragmentation on very big strings.
- `StringBuilder` has a richer API as the `ValueStringBuilder`. In the future they should have the same amount of API's as the `StringBuilder` is the "big brother" of this package.

## `ZString`
Both string builder use similiar concepts to achieve. Both,`ValueStringBuilder` and `ZString`, are declared as `struct`s. `ValueStringBuilder` goes one step further and enforces its lifecycle to live on the **stack** and can never be put on the **heap**.
Expand All @@ -22,6 +23,7 @@ Both string builder use similiar concepts to achieve. Both,`ValueStringBuilder`
* `ValueStringBuilder` is a `ref struct` which can never placed on the heap. `ZString` can be defined as a `class` field.
* `ZString` has a very big initial buffer in its default (64kb) which can lead to more pressure on the GC.
* `ZString` is more general purpose than `ValueStringBuilder` is.
* `ZString` offers a richer API than the `ValueStringBuilder`. In the future that should change.


## Benchmark
Expand Down
2 changes: 1 addition & 1 deletion docs/site/articles/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ Prints:
> Hello dear World!
0.3

[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/) and already has the `ValueStringBuilder` nuget package included.
[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/) and already has the `ValueStringBuilder` nuget package included in the latest version.

0 comments on commit 4aed915

Please sign in to comment.