-
Notifications
You must be signed in to change notification settings - Fork 75
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
Improving printing performance #961
Conversation
ad9687c
to
b966c71
Compare
@@ -8,7 +8,7 @@ import { | |||
const { group, indent, join, line, softline, hardline } = doc.builders; | |||
|
|||
export const printComments = (node, path, options, filter = () => true) => { | |||
if (!node.comments) return ''; | |||
if (!node.comments) return []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if this functions always returns an array, then we can always ask for comments.length
instead of comments?.length
b966c71
to
a699433
Compare
… calls across the code
… avoid wrapping the contents in a group.
…ing between a hardline and a line
a699433
to
d3c436b
Compare
This results in some code changes in the OpenZeppelin repository: diff --git a/contracts/access/extensions/AccessControlDefaultAdminRules.sol b/contracts/access/extensions/AccessControlDefaultAdminRules.sol
index ef71a648..73a8b66b 100644
--- a/contracts/access/extensions/AccessControlDefaultAdminRules.sol
+++ b/contracts/access/extensions/AccessControlDefaultAdminRules.sol
@@ -183,7 +183,7 @@ abstract contract AccessControlDefaultAdminRules is IAccessControlDefaultAdminRu
*/
function defaultAdminDelay() public view virtual returns (uint48) {
uint48 schedule = _pendingDelaySchedule;
- return (_isScheduleSet(schedule) && _hasSchedulePassed(schedule)) ? _pendingDelay : _currentDelay;
+ return _isScheduleSet(schedule) && _hasSchedulePassed(schedule) ? _pendingDelay : _currentDelay;
}
/**
@@ -191,7 +191,7 @@ abstract contract AccessControlDefaultAdminRules is IAccessControlDefaultAdminRu
*/
function pendingDefaultAdminDelay() public view virtual returns (uint48 newDelay, uint48 schedule) {
schedule = _pendingDelaySchedule;
- return (_isScheduleSet(schedule) && !_hasSchedulePassed(schedule)) ? (_pendingDelay, schedule) : (0, 0);
+ return _isScheduleSet(schedule) && !_hasSchedulePassed(schedule) ? (_pendingDelay, schedule) : (0, 0);
}
/**
diff --git a/contracts/governance/extensions/GovernorTimelockCompound.sol b/contracts/governance/extensions/GovernorTimelockCompound.sol
index 77cf369f..2837ca80 100644
--- a/contracts/governance/extensions/GovernorTimelockCompound.sol
+++ b/contracts/governance/extensions/GovernorTimelockCompound.sol
@@ -40,8 +40,8 @@ abstract contract GovernorTimelockCompound is Governor {
ProposalState currentState = super.state(proposalId);
return
- (currentState == ProposalState.Queued &&
- block.timestamp >= proposalEta(proposalId) + _timelock.GRACE_PERIOD())
+ currentState == ProposalState.Queued &&
+ block.timestamp >= proposalEta(proposalId) + _timelock.GRACE_PERIOD()
? ProposalState.Expired
: currentState;
}
diff --git a/lib/forge-std b/lib/forge-std
index c2236853..eb980e1d 160000
--- a/lib/forge-std
+++ b/lib/forge-std
@@ -1 +1 @@
-Subproject commit c2236853aadb8e2d9909bbecdc490099519b70a4
+Subproject commit eb980e1d4f0e8173ec27da77297ae411840c8ccb Maybe we are missing tests for ternaries whose condition is inside parentheses? Also, I used hyperfine to benchmark this change, and these are the results (again, in OZ) before and after the change:
So I don't think it has an impact, at least in that repo. That doesn't mean I'm against this change though, because it simplifies things anyway. |
Thank you for this, But that's for the future. |
All of the changes of this PR will be included in the TypeScript #968 step by step migration so I decided to close this one in favor to that one |
Removing
group
s that will always break:Removing
group
that just affect a closing bracket)
or]
that will be outside thetabWidth
Member Access Chain is already properly
group
edJust reordering the
group
indent
calls:Prefer using
shouldBreak
at thegroup
level instead of choosing betweenhardline
andline
The rest is wrapping strings together whenever possible.
Finally I rebased some functions that would
push
andconcat
into a variable and returned an built array instead.