StringBuilderHelper#5
Merged
electricessence merged 5 commits intomasterfrom Feb 24, 2024
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 fromstringtoStringBuilderHelperand for most simple concatenations work exactly the same but without the memory and performance overhead.