Skip to content

Conversation

@MaxHayman
Copy link

Doing a property like this I was noticing that the line was being printed twice.

    public uint Number
    {
        get
        {
            Console.WriteLine("Evaluated Number");
            return _testData.Number;
        }
    }

It was being evaluated in the isAllText call and allso in the CheckCriteria call in GenericArgsSatisfy.

Doing a ToList prevents this being evaluated multiple times by preventing multiple enumeration. I plan on having some not as fast logic behind some properties so evaluating these twice would be bad on performance.

This also leads to a ~15% performance increase in my testing.

Before

Method Mean Error StdDev Allocated
Test 946.8 ns 18.60 ns 33.54 ns 1.83 KB

After

Method Mean Error StdDev Allocated
Test 799.0 ns 11.86 ns 11.09 ns 1.68 KB

This also passes all the tests in the test project.

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