5 ms·
for (int i = 0; i < 10_000_000; i++) { s_result = s.Min; } Shouldn't your compiler completely fold this? There are no side effects, it's single
by olegkikin 9y ago
for (int i = 0; i < 10_000_000; i++)
{
s_result = s.Min;
}
Shouldn't your compiler completely fold this? There are no side effects, it's single-threaded. This should take microseconds, not 86 milliseconds.
- int_19h 9y agoIt's pretty tricky for the runtime to figure out that there are no side-effects, and that s.Min is not going to change, if the implementation behind it actually walks some nodes. Among other things, it would require it to prove that none of the walked nodes ever mutate anywhere else (don't forget that this includes backdoors like reflection).
- piaste 9y agoAre there any notable languages that flat-out forbid reflection, or treat it as undefined behaviour?