[exp] Remove always-run key re-indexing on every node#7646
[exp] Remove always-run key re-indexing on every node#7646TomasVotruba wants to merge 3 commits intomainfrom
Conversation
|
|
||
| // reindex stmt_key already covered on StmtKeyNodeVisitor on next processNodes() | ||
| // so set flag $reIndexStmtKey to false to avoid double loop | ||
| NodeAttributeReIndexer::reIndexNodeAttributes($node, false); |
There was a problem hiding this comment.
This should be kept, as reset index on other keyed values, the flag false is to not reindex stmt_key
| } | ||
|
|
||
| if ($node instanceof If_) { | ||
| $node->elseifs = array_values($node->elseifs); |
There was a problem hiding this comment.
If we are going to remove these, the BetterStandardPrintet need to be updated instead.
There was a problem hiding this comment.
This only called on after refactor, so should be fine to be kept
|
|
||
| // re-index stmt key under current node | ||
| foreach ($node->stmts as $key => $childStmt) { | ||
| $childStmt->setAttribute(AttributeKey::STMT_KEY, $key); |
There was a problem hiding this comment.
This is the part related with stmt_key set value. should be only remove this part only per related PRs.
|
I will create separate PR to only remove Other |
|
@TomasVotruba I created new PR for it for less bc break as possible :) |
|
This pull request has been automatically locked because it has been closed for 150 days. Please open a new PR if you want to continue the work. |
I'm working on removing STMT_KEY attribute in rules, where direct array key should be used instead.
The attribute can change any time and it doesn't make sense to use it, if the array key is there :)
At the moment the stmts key are re-indexed on every
enterNode()instead of just in the rules where code changed. That's a bit performance cost. Instead we should re-index array explicitly in the rule only when code is changed. This also promotes best practices to keep array stmts reliably indexed as list (0, 1, 2...).Let's see how many rules will this break and fix it propperly :)