Skip to content
This repository has been archived by the owner on Nov 22, 2023. It is now read-only.

Add Buffer.Equals #334

Closed
wants to merge 2 commits into from
Closed

Conversation

shargon
Copy link
Member

@shargon shargon commented Jun 17, 2020

Related to #332 (comment)

@shargon shargon requested a review from erikzhang June 17, 2020 09:29
@shargon
Copy link
Member Author

shargon commented Jun 17, 2020

@ixje Please take a look

@erikzhang
Copy link
Member

If you think of Buffer as a StringBuilder, I don’t think you should compare them by content. Because their content will change at any time.

@Tommo-L
Copy link
Contributor

Tommo-L commented Jun 23, 2020

If you think of Buffer as a StringBuilder, I don’t think you should compare them by content. Because their content will change at any time.

But in c# contract, byte[] also is converted to Buffer. And in c#, both byte[] and string can be compared, concated, sliced, etc. If we add them, it seems there is no negative effect. Or we implement them in compiler?

@erikzhang
Copy link
Member

And in c#, both byte[] and string can be compared

Of course not. You can test it. byte[] can't be compared.

byte[] a = { 1, 2, 3 };
byte[] b = { 1, 2, 3 };
bool c = a == b; // Should be false

@shargon
Copy link
Member Author

shargon commented Jun 23, 2020

Agree with erik, but I think that it could be faster if we want to check if one address it's the owner address, what opcode should we use?

@erikzhang
Copy link
Member

PUSH 0x0011223344556677889900112233445566778899
EQUAL

I don't think any addresses are spliced out.

@erikzhang erikzhang closed this Aug 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants