Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use static closures for minor performance improvement whenever instance access is not needed #729

Merged
merged 8 commits into from
Jun 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions admin/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function perflab_load_modules_page( $modules = null, $focus_areas = null ) {
add_settings_field(
$module_slug,
$module_data['name'],
function() use ( $module_slug, $module_data, $module_settings ) {
static function() use ( $module_slug, $module_data, $module_settings ) {
perflab_render_modules_page_field( $module_slug, $module_data, $module_settings );
},
PERFLAB_MODULES_SCREEN,
Expand Down Expand Up @@ -332,7 +332,7 @@ function perflab_get_modules( $modules_root = null ) {

uasort(
$modules,
function( $a, $b ) {
static function( $a, $b ) {
return strnatcasecmp( $a['name'], $b['name'] );
}
);
Expand Down Expand Up @@ -442,7 +442,7 @@ function perflab_admin_pointer( $hook_suffix ) {
wp_enqueue_script( 'wp-pointer' );
add_action(
'admin_print_footer_scripts',
function() {
static function() {
$content = __( 'The SQLite module will be removed in the upcoming Performance Lab release in favor of a standalone plugin.', 'performance-lab' );
$content .= ' ' . sprintf(
/* translators: %s: settings page link */
Expand Down Expand Up @@ -580,7 +580,7 @@ function perflab_dismiss_wp_pointer_wrapper() {
*/
add_action(
'admin_notices',
function() {
static function() {
global $hook_suffix;

// Only show in the WordPress dashboard and Performance Lab admin screen.
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"wp-phpunit/wp-phpunit": "^5.8",
"yoast/phpunit-polyfills": "^1.0",
"phpstan/phpstan-phpunit": "^1.3",
"phpstan/phpstan-deprecation-rules": "^1.1"
"phpstan/phpstan-deprecation-rules": "^1.1",
"slevomat/coding-standard": "^8.0"
},
"require": {
"composer/installers": "~1.0",
Expand Down
194 changes: 150 additions & 44 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading