Optimizations, Architectural Improvements and Bug Fixes#4
Merged
CaseyHofland merged 10 commits intomasterfrom Jul 29, 2025
Merged
Optimizations, Architectural Improvements and Bug Fixes#4CaseyHofland merged 10 commits intomasterfrom
CaseyHofland merged 10 commits intomasterfrom
Conversation
…eatmap3, and Heatmap3to2. Add settings to benchmarks on startup. This enables the use of starting up benchmarks from the command line with arguments.
…rialize data types as arrays of a single unmanaged type, like Vectors and Matrices.
…r and deprecate it for backwards compatability.
Change HeatmapJsonConverters to inherit from JsonConverter<TInput> and be much more performant.
Counter<TItem> is a wrapper for Dictionary<TItem, int> that makes it simple to count items. For example:
```csharp
public class Program
{
public static void Main()
{
var counter = new Counter<string>();
counter.Add("hello", 3);
var i = counter["hello"]; // returns 3
counter.Add("hello"); // Same as counter.Add("hello", 1);
i = counter["hello"]; // returns 4
counter.Remove("hello", 2);
i = counter["hello"]; // returns 2
}
}
```
This removes a lot of the similar code from both classes and makes the implementation more consistent.
A utility method for turning a boolean into an int / number.
This ensures that the library is build with invariant globalization in mind, making it function the same way across all regions.
This change was made so that seperate packages may be build and sold from this software.
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.
This update makes a lot of improvements while keeping previous code intact, if not deprecated in certain places.
JsonConverter<TInput, TOutput>SpanJsonConverter<T, U>orJsonConverter<T>JsonSerializerJsonStreamSerializerThe deprecation of
JsonSerializertoJsonStreamSerializeris simply a name change. Both classes function exactly the same, but the later name better conveys the intent of the class (anIStreamSerializerfor Json serialization) and doesn't conflict with theJsonSerializerclass in theSystem.Text.Jsonnamespace. This is but a minor gripe, but a nice one to avoid.This update also deprecates the
JsonConverter<TInput, TOutput>. The HeatmapJsonConverters have been changed to inherit fromJsonConverter<T>, and the NumericJsonConverters have been changed to inherit from theSpanJsonConverter<T, U>, a very fastJsonConverter<T>for serializing a data type to, and deserializing a data type from, an array of an unmanaged type. TheSpanJsonConverter<T>allocates no extra memory serializing and deserializing the object by working directly with existing memory through the use of Spans.To unify the heatmap implementations, a new class
Counter<T>has been made and -parented toHeatmap2,Heatmap3, andHeatmap3to2. ACounter<T>is a wrapper for aDictionary<T, int>that makes it simple to count items. Heatmaps are effectively positional counters, hence can inherit from this generic class. It may also be repurposed in different scenarios.Other additions include the
BooleanExtensionsclass with a utility function for converting a boolean to an int withToInt()or a number withToNumber<T>(), setting the projects globalization to invariant for consistent functionality across different regions, and changing the license from GNU to MIT.Cheers.