contract test {
address public _onwer;
error NotOwner();
modifier OnlyOwner1() {
if(msg.sender != _onwer) {
revert NotOwner();
}
_;
}
function OnlyOwner2() private view {
if(msg.sender != _onwer) {
revert NotOwner();
}
}
function toDoSomething1() public view OnlyOwner1() {
// to do something
}
function toDoSomething2() public view {
OnlyOwner2();
// to do something
}
}
Looking at the above code as an example toDoSomething1() and toDoSomething2(), which method is more efficient, modifier(OnlyOwner1()) or function(OnlyOwner2())?
I would really appreciate it if you could explain why.