Performance Improvement: Eliminate the unnecessary load of the viewing user's buddies in buddylist_get_buddy_actions
klktrk - November 15, 2008 - 01:47
| Project: | Buddylist |
| Version: | HEAD |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | needs review |
Jump to:
Description
The function buddylist_get_buddy_actions contains a simple flip in logic that almost doubles the load of each user's profile page when viewed by a logged in user.
There is no need to grab the viewing user's buddy list, since if the viewing user *is* a buddy already, the viewing
user's id should be in the viewed user's buddy list, since the lists are reciprocal. This should give a big boost to busy sites.
The attached patch simply flips the logic from this:
else if (in_array($viewed_user->uid, array_keys(buddylist_get_buddies($viewing_user->uid)))) {
$actions[] = theme('remove_from_buddylist_link', $viewed_user);
}to this:
else if (in_array($viewing_user->uid, array_keys(buddylist_get_buddies($viewed_user->uid)))) {
$actions[] = theme('remove_from_buddylist_link', $viewed_user);
}We can't for the life of us figure out why this was done in the first place, or are we missing something?
Thanks.
| Attachment | Size |
|---|---|
| buddylist_improve_actions_performance.patch | 755 bytes |

#1
Title edit.
#2
Bouncing. Anybody there?