Skip to content

Commit

Permalink
Merge pull request #729 from WordPress/add/static-closures
Browse files Browse the repository at this point in the history
Use static closures for minor performance improvement whenever instance access is not needed
  • Loading branch information
felixarntz authored Jun 13, 2023
2 parents 92338e3 + 6e8833b commit 2d2f5f2
Show file tree
Hide file tree
Showing 24 changed files with 215 additions and 105 deletions.
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

0 comments on commit 2d2f5f2

Please sign in to comment.