You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using > 0 costs more gas than != 0 when used on a uint in a require() statement > 0
contracts\Community.sol:
763 // Revert if repayment amount is zero.
764: require(_repayAmount > 0, "Community::!repay");
contracts\Project.sol:
194 // Revert if try to lend 0
195: require(_cost > 0, "Project::!value>0");
It costs more gas to initialize variables to zero than to let the default of zero be applied
contracts\Project.sol:
247 // Loop over all the new tasks.
248: for (uint256 i = 0; i < _length; i++) {
249 // Increment local task counter.
310 // Invite subcontractor for each task.
311: for (uint256 i = 0; i < _length; i++) {
312 _inviteSC(_taskList[i], _scList[i], false);
321 uint256 _length = _taskList.length;
322: for (uint256 i = 0; i < _length; i++) {
323 tasks[_taskList[i]].acceptInvitation(_msgSender());
x = x + y is cheaper than x += y
contracts\Community.sol:
422 .projectDetails[_project]
423: .totalLent += _amountToProject;
424
434 .projectDetails[_project]
435: .lentAmount += _lendingAmount;
436
contracts\HomeFi.sol:
288 // Project count starts from 1
289: projectCount += 1;
290
contracts\Project.sol:
178 // Increment to ensure a set of data and signature cannot be re-used.
179: hashChangeNonce += 1;
180
249 // Increment local task counter.
250: _taskCount += 1;
251
289 // Increment to ensure a set of data and signature cannot be re-used.
290: hashChangeNonce += 1;
291
439 // Increase the difference of new cost and old cost to total allocated.
440: totalAllocated += _newCost - _taskCost;
441 }
710 for (uint256 _taskID = 1; _taskID <= _length; _taskID++) {
711: _cost += tasks[_taskID].cost;
712 }
The text was updated successfully, but these errors were encountered:
Using
> 0
costs more gas than!= 0
when used on auint
in arequire()
statement> 0
It costs more gas to initialize variables to zero than to let the default of zero be applied
x = x + y
is cheaper thanx += y
The text was updated successfully, but these errors were encountered: