Skip to content

NumberExtensions should not use Convert for net7.0 #1483

@lipchev

Description

@lipchev

I just noticed this simple performance improvement that's likely to have a huge performance impact on the NumberExtensions..

        public static Mass Centigrams<T>(this T value)
            where T : notnull
#if NET7_0_OR_GREATER
            , INumber<T>
            => Mass.FromCentigrams(double.CreateChecked(value));
#else
            => Mass.FromCentigrams(Convert.ToDouble(value));
#endif

Not sure if we want this in v5, v6 or I could just put it up-for-grabs and leave it for later..

Note that there is probably a Convert.ToDecimal somewhere, just waiting to popup as a merge conflict...

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementpinnedIssues that should not be auto-closed due to inactivity.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions