On 08/25/2016 08:15 PM, Basile B. wrote:
Here's a better code to illustrate the idea:
°°°°°°°°°°°°°°°°°°°°°°
interface Foo
{
int foo() const;
}
int use(const(Foo) foo)
{
return foo.foo() + foo.foo();
}
°°°°°°°°°°°°°°°°°°°°°°
And I'd expect this asm for a 'const optimization' in use():
push rbp
push rbx
push rax
mov rbx, rdi
mov rax, qword ptr [rbx]
call qword ptr [rax+08h]
add eax, eax // const funct = no side effect, so add the 1st result =
save a CALL
add rsp, 08h
pop rbx
pop rbp
ret
At least, foo needs to be `pure` for that.