Conversation
| if (!_isOwnerOfProfile(_profileId, msg.sender)) { | ||
| revert UNAUTHORIZED(); | ||
| } | ||
| _checkOnlyProfileOwner(_profileId); |
There was a problem hiding this comment.
I don't think we need to do this, it is only used in this one place, so you are still following SOLID principles.
There was a problem hiding this comment.
Looks like I was late in explaining and showing the result of the change we can get, but anyways
Yeah, I know that internal function was used at just one place, but it's related to modifier which is kind of used up several times. Try to run some tests and we be getting a clear scenario.
| /// ======== Internal Functions ======== | ||
| /// ==================================== | ||
|
|
||
| /// @dev Internal function used by modifier 'onlyProfileOwner' |
There was a problem hiding this comment.
Take a look -> OpenZeppelin/openzeppelin-contracts#3347
Also this one -> OpenZeppelin/openzeppelin-contracts#3223
|
Quite a demo related to 2nd change (Modifiers one) So I created a similar basic look code, which have two modifiers onlyBuyer and onlySeller and they are being used in 3 and 5 functions respectively (just for mimicking the original one). Here's the code: At first, I ran this code with simple modifiers like we usually use and clicked a snapshot of the amount of gas it used: and then after making the required changes like I have done in this PR, or just see the code itself (the changed part): I got these results which were really striking!! That's it, Thanks for making a through reading!! |
1036819 to
6776e5a
Compare
8acb2b8 to
6776e5a
Compare




Three types of changes made in this PR:
1st -> changing
uint256 i = 0touint256 i, explained in #2882nd -> Making an internal function for the modifier
onlyProfileOwnerwhich kind of appeared 5-6 times in that particular file..Explaination: Usually modifiers just copy paste their code whenever they are used in any function, thus costs some amount of gas, but creating an internal function and aligning it with our modifier really drops down the gas usage at the cost of JUMP opcode
3rd -> Just some typos and grammatical errors in the comments, usually a change of
an membertoa member