Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I feel like I should just post the patches since I tend to post the patch right after putting up the issue.
Fix for Related to gh-268.
Essentially this will take the amount of iterations required to populate a result say a lot closer to something like 2N, where N is the number of models + relations loaded, as opposed to N^2.
I created a hash map to store all of the possible relations (
$all_related_with_value
), and instead of looping over every found relation for every found model, it will directly pull the relations from the hash map, which is an instant lookup.Also since this was an optimization, I also changed
$used_models
to store the hash as and usingarray_key_exists
instead of usingin_array()
, as in_array requires php to check every value of the array as opposed to just instantly pulling the value from the hash.