@@ -42,39 +42,6 @@ public record DataMethodBodyBuilderStage4<TParam1, TReturnType>(BodyGenerationDa
4242
4343 public IMethodBodyGenerator BodyReturningConstant ( Func < TReturnType > constantValueFactory ) =>
4444 new DataMethodBodyGenerator ( Data with { ReturnConstantValueFactory = constantValueFactory } ) ;
45-
46- public IMethodBodyGeneratorSwitchBody < TParam1 , TReturnType > BodyWithSwitchStatement ( )
47- => throw new NotImplementedException ( ) ; //TODO: Remove explicit SwitchStatements with `for` and `constants`, like so:
48- /*
49- .ForMethod().WithReturnType<int>().WithParameter<int>()
50- .BodyWithSwitchStatement()
51- .ForCases(0, 1, 2, 300, 301, 302, 303).ReturnConstantValue(decimalNumber => SlowMath.CalculatePiDecimal(decimalNumber))
52- .ForDefaultCase().UseProvidedBody(decimalNumber => SlowMath.CalculatePiDecimal(decimalNumber));
53-
54- Will be replaced with:
55-
56- .ForMethod().WithReturnType<int>().WithParameter<int>()
57- .WithCompileTimeConstants(() => new
58- {
59- PrecomputedTargets = new HashSet<int>(new int[] { 0, 1, 2, 300, 301, 302, 303 })
60- })
61- .UseProvidedBody(decimalNumber, constants =>
62- {
63- if (constants.PrecomputedTargets.Contains(decimalNumber)) return SlowMath.CalculatePiDecimal(decimalNumber);
64- else return SlowMath.CalculatePiDecimal(decimalNumber);
65- });
66-
67- Or (in the case of PI), just simply:
68-
69- .ForMethod().WithReturnType<int>().WithParameter<int>()
70- .UseProvidedBody(decimalNumber =>
71- {
72- var precomputedTargets = new HashSet<int>(new int[] { 0, 1, 2, 300, 301, 302, 303 })
73-
74- if (precomputedTargets.Contains(decimalNumber)) return SlowMath.CalculatePiDecimal(decimalNumber);
75- else return SlowMath.CalculatePiDecimal(decimalNumber);
76- });
77- */
7845}
7946
8047public record DataMethodBodyBuilderStage4NoArg < TReturnType > ( BodyGenerationData Data ) : IMethodBodyBuilderStage4NoArg < TReturnType >
0 commit comments