Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi,
countries_countries_alter() contains following code:
$countries = array_intersect_key($enabled_countries, $countries);
$countries = array_merge($countries, array_diff_key($enabled_countries, $countries));
uasort($countries, 'countries_sort');
I might be wrong, but I think $countries and $enabled_countries will always be equal at the end? And since $enabled_countries was already sorted in countries_get_countries() we can save a lot of sorting overhead (+-10 seconds in my case)...
Patch forthcoming.
Comment | File | Size | Author |
---|---|---|---|
#1 | countries-hook-countries-alter-overhead-2027613-1.patch | 581 bytes | Matthijs |
Comments
Comment #1
MatthijsComment #2
Alan D. CreditAttribution: Alan D. commentedI think the logic here was meant to update the existing countries then to merge in any additional ones that were coming in from the $countries parameter that were not defined within the Countries module. However, as it is written, there is a logical error that breaks this and you effectively do have what your patch does.
Personally, happy to pass all responsibility to the countries module, so RTBTC from me :)
Comment #3
Alan D. CreditAttribution: Alan D. commentedand pushed.
Thanks
Comment #4
MatthijsGreat, thanks!
Matthijs
Comment #5.0
(not verified) CreditAttribution: commentedRemoved solution code (it's in the patch).