« first day (2 days earlier)  last day (15 days later) » 

10:04
Hi again. So the problem is that, in general the copy memory -> memory is the abi encoding of the memory object. In general, it may not be the same.
In this case, the encoding is the same, though.
@NikaKurashvili tagging just in case, you don't get notified otherwise.
 
2 hours later…
11:41
Hi
still there ?
@hrkrshnn
11:53
Yep
I didn't quite understand something
even if it does abi encoding, the space will still be required in memory, the same size or more, because in the encoding, we also need to store sizes and all that if it's dynamic
makes sense ?
@hrkrshnn
But the abi encoding can be different. Which is why you need a copy.
In your example, you don't need a copy.
1. but it still copies
doesn't it ?
Yes. This is the job of the optimizer. It currently can't handle this case.
That is, to remove the unnecessary copy.
why does it store abi encoding at all ?
so it copied from calldata to memory let's say [99,101] array
now as you're saying it puts abi.encode([99,101]) in the memory again before calling the function, right ?
12:02
Yeah.
I just don't get why .
You need to store it before you do the external call.
That's the thing! why ? :D
How else would you do it?
you already have it in memory
use it !!!
12:04
For one, it's not in the memory after you do the external call.
when you do the external call, it goes as the calldata for the callee function
so what you're saying is the following
it abi encodes the data
puts it in memory again
and before using call opcode, it takes this newly data (abi encoded) in memory and passes as calldata
am I right ?
```
contract C {
    function f() public returns(uint r) {
        assembly {
            r := mload(10000)
        }
    }
}

contract D {
    C c = new C();

    function g() public returns(uint old, uint intme, uint aft, uint Cmemory) {
        assembly {
            old := mload(10000)
            mstore(10000, 200)
            intme := mload(10000)
        }

        Cmemory = c.f();

        assembly {
            aft := mload(10000)
        }
    }
}
```
I will take a look at it, but could you agree to this ?

so what you're saying is the following
it abi encodes the data
puts it in memory again
and before using call opcode, it takes this newly data (abi encoded) in memory and passes as calldata
am I right ?
In this example, r would return 0.
Yeah. That sounds right.
i think
that abi encoded data will always be bigger than the actual data
:D
that's for sure.. there's no other way around, because for arrays, it also stores length in the encoded data
our question was why it can't just encode the already existing data and use it instead of putting it again in memory, right ?
12:08
Yeah. This has to be done by the optimizer.
seems like even if the encoding are the same, it just puts it again in memory
at least, we figured it out !
any chance we can exchange contacts on slack or discord or something for the quicker discussions when one needs something ?
How about matrix?
what's that ?
I'm @hrkrshnn on gitter. And @hrkrshnn:matrix.org on matrix
installing the matrix now..
12:12
You can generally ask on gitter.im/ethereum/solidity
If it's more about improving the compiler, you can ask on gitter.im/ethereum/solidity-dev
Thanks for the help.. I think I added you on matrix
ping me if you got it

« first day (2 days earlier)  last day (15 days later) »