dotnet / dotnet/efcore

Optimize constant arithmetic

Open
#28,036 1 comment 0 reactions 0 assignees View on GitHub
area-perf area-query
Dominant language
C#
Stars
14.8k
Forks
3.4k
PR merge metrics
PR metrics pending

Description

Some function translations apply arithmetic to arguments/return values; when the operands happen to be constants, we can simply compute the result in post-translation and embed the result constant.

See #28031 for an example with SQL Server's string.IndexOf.

It may be a good idea to do some non-arithmatic evaluation as well (IIRC there's some logical optimization happening in SqlNullabilityProcessor, which may make more sense in a general optimizing visitor or something).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.