Skip to content

StringBuilderHelper#5

Merged
electricessence merged 5 commits intomasterfrom
StringBuilderHelper
Feb 24, 2024
Merged

StringBuilderHelper#5
electricessence merged 5 commits intomasterfrom
StringBuilderHelper

Conversation

@electricessence
Copy link
Copy Markdown
Collaborator

StringBuilders are great, but they can be slightly more clunky to work with than just strings.
Some older code will use and abuse += with strings. This allows for simply changing the declared type from string to StringBuilderHelper and for most simple concatenations work exactly the same but without the memory and performance overhead.

…structures to handle character sequences and their enumeration. The `CharacterSequence` struct, `StringBuilderEnumerator` struct, `StringConcat` class, and `StringSegmentEnumerator` struct have been added to represent and manipulate sequences of characters. Additionally, the `Equals` method in both `StringComparable.cs` and `StringSubsegment.cs` has been updated to allow for nullable objects.

Here is a list of the changes:

1. The `Equals` method in `StringComparable.cs` has been updated to allow for nullable objects. This change enhances the method's flexibility in handling different types of inputs.
2. The `GetHashCode` method in `StringComparable.cs` has been updated to handle different .NET Standard versions. This ensures the method's compatibility across different .NET Standard versions.
3. The `StringSegmentComparer` class in `StringSegmentComparer.cs` has been updated to include additional parameters in the constructor and their corresponding properties. This allows for more detailed object instantiation.
4. The `Equals` method in `StringSubsegment.cs` has been updated to allow for nullable objects. This enhances the method's flexibility in handling different types of inputs.
5. A new `CharacterSequence` struct has been added in `CharacterSequence.cs` to represent a sequence of characters. This provides a new way to handle character sequences.
6. A new `StringBuilderEnumerator` struct has been added in `StringBuilderEnumerator.cs` to enumerate the characters in a `StringBuilder`. This provides a new way to iterate through the characters in a `StringBuilder`.
7. A new `StringConcat` class has been added in `StringConcat.cs` to concatenate sequences of characters. This provides a new way to concatenate character sequences.
8. A new `StringSegmentEnumerator` struct has been added in `StringSegmentEnumerator.cs` to enumerate the characters in a `StringSegment`. This provides a new way to iterate through the characters in a `StringSegment`.
9. New tests for the `StringConcat` class have been added in `StringConcatTests.cs`. This ensures the `StringConcat` class functions as expected.
…` file to include new C# style preferences and to silence certain diagnostics. The target framework of the `Open.Text.Benchmarks.csproj` project was updated from `net6.0` to `net8.0`. In `Program.cs`, the benchmark test was changed from `EnumParseTests` to `StringConcatTests`. New methods and classes were added to `StringBuilderExtensions.cs`, `StringConcat.cs`, `StringConcatTests.cs`, and `StringBuilderHelper.cs` to improve string concatenation operations.

1. The `.editorconfig` file was updated to include new C# style preferences and to silence certain diagnostics. This change will help to enforce coding style consistency across the project.
2. The target framework of the `Open.Text.Benchmarks.csproj` project was updated from `net6.0` to `net8.0`. This change will allow the project to take advantage of the latest .NET features.
3. In `Program.cs`, the line `BenchmarkRunner.Run<EnumParseTests>();` was commented out and replaced with `BenchmarkRunner.Run<StringConcatTests>();`. This change shifts the focus of the benchmarking from enum parsing to string concatenation.
4. In `StringBuilderExtensions.cs`, the `TrimEnd` method was updated and a new `Append` method was added that appends the characters from another `StringBuilder` instance. These changes enhance the functionality of the `StringBuilderExtensions` class.
5. In `StringConcat.cs`, the implicit operator method was updated to return `value?.ToString();` instead of `value?.ToString()!;`. This change makes the method more null-safe.
6. A new file `StringConcatTests.cs` was added, which includes a new `StringConcatTests` class for benchmarking different string concatenation methods. This addition provides a way to measure the performance of various string concatenation techniques.
7. A new file `StringBuilderHelper.cs` was added, which includes a new `StringBuilderHelper` class that provides various operator overloads for appending characters to a `StringBuilder` instance. This addition enhances the functionality of the `StringBuilder` class.
@electricessence electricessence merged commit 160f973 into master Feb 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant