Skip to content
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

[DeadCode] Improve RemoveUnreachableStatementRector performance by return after array_splice early #2193

Merged
merged 3 commits into from
Apr 29, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
use array_splice
samsonasik committed Apr 29, 2022

Verified

This commit was signed with the committer’s verified signature.
samsonasik Abdul Malik Ikhsan
commit 0204fc6e717d07935ff26e93a2c0683ab90c4eaf
Original file line number Diff line number Diff line change
@@ -120,10 +120,7 @@ public function refactor(Node $node): ?Node
*/
private function processCleanUpUnreachabelStmts(array $stmts): array
{
$cleanedStmts = [];
foreach ($stmts as $key => $stmt) {
$cleanedStmts[] = $stmt;

if (! isset($stmts[$key - 1])) {
continue;
}
@@ -135,8 +132,8 @@ private function processCleanUpUnreachabelStmts(array $stmts): array
$previousStmt = $stmts[$key - 1];

if ($this->shouldRemove($previousStmt, $stmt)) {
array_pop($cleanedStmts);
return $cleanedStmts;
array_splice($stmts, $key);
return $stmts;
}
}