sebastienros / fluid

Fluid is an open-source .NET template engine based on the Liquid template language.
MIT License
1.41k stars 176 forks source link

Seal types not suitable for extending #611

Closed lahma closed 9 months ago

lahma commented 9 months ago

CLR can make better decisions when it knows there's no worry to do virtual calls to ensure that possible overridden method would be correctly called. Types really don't have extension points via inheritance.

Fluid.Benchmarks.FluidBenchmarks

Diff Method Mean Error Allocated
Old Parse 3.193 μs 0.0312 μs 2.68 KB
New 3.152 μs (-1%) 0.0307 μs 2.68 KB (0%)
Old ParseBig 16.892 μs 0.2980 μs 11.61 KB
New 16.840 μs (0%) 0.2747 μs 11.61 KB (0%)
Old Render 133.681 μs 2.5941 μs 95.86 KB
New 130.399 μs (-2%) 1.4315 μs 95.86 KB (0%)
Old ParseAndRender 135.980 μs 1.5126 μs 99.01 KB
New 135.876 μs (0%) 2.0597 μs 99.01 KB (0%)
sebastienros commented 9 months ago

I fear that it will break someone. But let's try and see people complain, the current version being quite stable they shouldn't need to upgrade and won't be blocked.

lahma commented 9 months ago

This was my thinking too, let's break it and unseal when needed.