Skip to content

run array_unique() only once per class#1088

Closed
staabm wants to merge 1 commit intosebastianbergmann:mainfrom
staabm:less-nesting
Closed

run array_unique() only once per class#1088
staabm wants to merge 1 commit intosebastianbergmann:mainfrom
staabm:less-nesting

Conversation

@staabm
Copy link
Copy Markdown
Contributor

@staabm staabm commented Aug 28, 2025

at this point its mostly guess work.

having loops after each other should be faster then nested loops though - O(3n) vs. O(n^2).

Comment thread src/Target/MapBuilder.php
$classes[$parentClass->namespacedName()],
);

foreach ($merged as $mergedFile => $lines) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this loop moved after the outer loop

Comment thread src/Target/MapBuilder.php

foreach ($merged as $mergedFile => $lines) {
$merged[$mergedFile] = array_unique($lines);
if (!isset($classesThatExtendClass[$parentClass->namespacedName()])) {
Copy link
Copy Markdown
Contributor Author

@staabm staabm Aug 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved this if-condition, so we reflect the same structure as the foreach-loop above (just readability)

@staabm staabm marked this pull request as draft August 29, 2025 06:31
@staabm
Copy link
Copy Markdown
Contributor Author

staabm commented Aug 29, 2025

we need to be more incremental as our problem is memory, not cpu: #1089

@staabm staabm closed this Aug 29, 2025
@staabm staabm deleted the less-nesting branch August 29, 2025 06:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant