By my understanding, what you're talking about is to pre-calculate at compile time with what is known by the compiler.
Yes.
А продолжение - нет. Потому что всё остальное - это ваши домыслы.
Я не предлагал менять что-то в процессе вычисления. А предлагал указать компилятору дополнительные "точки", с помощью которых компилятор будет быстрее вычислять конечный результат.
То, о чём пишите вы, не относится к компиляции. Это чистое изменение кода. И в таких ситуация решать программисту, надо делать это или нет. Но ни как не компилятору!
И покажу вам код, что предлагаю я.
Yandex translate:
And the continuation is not. Because everything else is your speculation.
I didn't suggest changing anything in the calculation process. I suggested specifying additional "points" to the compiler, with which the compiler will calculate the final result faster.
What you are writing about does not apply to compilation. This is a pure code change. And in such situations, it's up to the programmer to decide whether to do it or not. But not the compiler!
And I'll show you the code that I offer.
The original code:
for Count := 0 to MAX_TEST do // MAX_TEST = 1000000
begin
mS1 := nn + 66 + 35;
mS2 := mS1 - 54 - 22;
mS3 := ms1 / 22;
end;
The final code:
n2 := 35;
n5 := 66;
n6 := 54;
mS4 := 22;
for Count := 0 to MAX_TEST do
begin
mS1 := n2 + nn + n5;
mS2 := mS1 - n6 - mS4;
mS3 := ms1 / mS4;
end;
В итоге ни чего не поменялось, но изменённый код будет работать немного быстрее. А в больших программах вероятнее всего программа может выдать намного большее ускорение конечной программы. Хотя бы по той причине, что на большинстве участков кода используются не оптимизированные данные. Даже при вызове процедур/функций.
Оптимизировать можно много всего, даже не изменяя конечного кода программы (у меня ускорение чуть меньше 8%).
Yandex translate:
As a result, nothing has changed, but the modified code will work a little faster. And in large programs, most likely the program can give a much greater acceleration of the final program. At least for the reason that most parts of the code use non-optimized data. Even when calling procedures/functions.
You can optimize a lot of things without even changing the final program code (I have a slightly less than 8% acceleration).
P.S. хотя большинству из вас это не нужно, вы даже заморачиваться подобным не будете. / although most of you don't need it, you won't even bother with it.