-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pass (large) strings by value and move if they are to be consumed #6216
Comments
Hi, quick question for further clarification... The function you mention it is defined as such:
Variable It is my understanding that in cpp passing by constant reference does not cause a copy. Citing IBM: So my question is where does the unnecessary copy occur? |
You are right that passing by You might be able to find more information here: https://stackoverflow.com/questions/270408/is-it-better-in-c-to-pass-by-value-or-pass-by-constant-reference |
Thank you very much! |
Issue Status: 1. Open 2. Started 3. Submitted 4. Done Work has been started. These users each claimed they can complete the work by 4 days, 19 hours ago. 1) g-r-a-n-t has been approved to start work. Looks pretty straight forward. AP:
Learn more on the Gitcoin Issue Details page. |
@g-r-a-n-t Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!
Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days |
@g-r-a-n-t Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!
Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days |
Hello @gitcoinbot, this is currently under review. |
Issue Status: 1. Open 2. Started 3. Submitted 4. Done Work for 200.0 DAI (200.0 USD @ $1.0/DAI) has been submitted by: @vs77bb please take a look at the submitted work:
|
@vs77bb Could you please take a look at this work? |
|
Issue Status: 1. Open 2. Started 3. Submitted 4. Done The funding of 200.0 DAI (200.0 USD @ $1.0/DAI) attached to this issue has been approved & issued to @g-r-a-n-t.
|
Solved by #6490 |
Especially when setting the source input of the compiler, these strings are passed by const reference. This forces a copy which would actually be unnecessary. The recommended way of passing data that is consumed/stored by the function/method is to pass by value and move into the member variable.
There are several instances where solidity sources stored in strings are copied instead of moved like that, for example in
CompilerStack::addSource
. This should be fixed.The text was updated successfully, but these errors were encountered: