Skip to content

Conversation

@anther
Copy link
Contributor

@anther anther commented Mar 15, 2013

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 using array_key_exists instead of using in_array(), as in_array requires php to check every value of the array as opposed to just instantly pulling the value from the hash.

@al-the-x
Copy link
Collaborator

Thanks, that was helpful. ;)

@al-the-x al-the-x mentioned this pull request Jul 29, 2013
@koenpunt koenpunt mentioned this pull request Jul 17, 2014
27 tasks
@koenpunt koenpunt mentioned this pull request Dec 7, 2014
@koenpunt
Copy link
Collaborator

koenpunt commented Dec 7, 2014

Closing in favor of #466

@koenpunt koenpunt closed this Dec 7, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants