Change Equals() to only compare Value. #32
Closed
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 is a follow up on #30 that suggests changing
Equals()
andGetHashCode()
to only compareValue
. Advantages are explained in the issue description.This PR also contains the following:
TryFromName()
andTryFromValue()
methods. These allow searching without exceptions thrown, improving considerably performance.ignoreCase
parameter toFromName()
andTryFromName()
. The defaut value istrue
to not break previous contract but, this is not the usual default value for this option and has considerably worst performance.Equals Benchmarks
The performance much better than for current master branch or even with changes proposed in #26 .
Search Benchmarks
The use os dictionaries make all search operations to have O(1) complexity. The use of exception is considerably slower than
TryFromName()
andTryFromValue()
that are actually faster when value is invalid than when valid. Case sensitive searching is faster than when casing ignored.