Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
06/11/2015 06:53:59 AM (11 years ago)
Author:
johnjamesjacoby
Message:

Loaders: Micro-optimizations:

  • Add brackets for improved readability
  • Only instantiate $bp from buddypress() when used more than once, and after all early return conditions have executed
  • Use _slug_ functions where appropriate, and avoid $this->slug references as they do not run filters
  • Reduce mulitple calls to the same functions into 1 function call: I.E. bp_core_can_edit_settings()
  • Remove BP_Core_Component::setup_nav() method - it's been handled and duplicated by BP_Members_Component for several years now, and only when XProfile is disabled
  • Use new bp_get_profile_slug() functions where appropriate
  • Use bp_core_number_format() where appropriate
  • Avoid duplicate trailingslashit() calls on the same variables
  • Rely on canonical menu URLs for all components

This change touches each component's -loader.php file and makes several small optimizations that avoid executing hundreds of function calls that return data (specifically gettext) that never gets used on logged-out users. This results in an approximate 20% reduction in time spent running our full unit test suite in my testing, and also improves site performance for logged-out users.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/routing/xprofile.php

    r9819 r9936  
    2020
    2121        function test_member_profile() {
    22                 $this->go_to( bp_core_get_user_domain( bp_loggedin_user_id() ) . buddypress()->profile->slug );
     22                $this->go_to( bp_core_get_user_domain( bp_loggedin_user_id() ) . bp_get_profile_slug() );
    2323                $this->assertTrue( bp_is_user_profile() );
    2424        }
    2525
    2626        function test_member_profile_edit() {
    27                 $this->go_to( bp_core_get_user_domain( bp_loggedin_user_id() ) . buddypress()->profile->slug . '/edit' );
     27                $this->go_to( bp_core_get_user_domain( bp_loggedin_user_id() ) . bp_get_profile_slug() . '/edit' );
    2828                $this->assertTrue( bp_is_user_profile_edit() );
    2929        }
    3030
    3131        function test_member_profile_change_avatar() {
    32                 $this->go_to( bp_core_get_user_domain( bp_loggedin_user_id() ) . buddypress()->profile->slug . '/change-avatar' );
     32                $this->go_to( bp_core_get_user_domain( bp_loggedin_user_id() ) . bp_get_profile_slug() . '/change-avatar' );
    3333                $this->assertTrue( bp_is_user_change_avatar() );
    3434        }
Note: See TracChangeset for help on using the changeset viewer.