Make WordPress Core


Ignore:
Timestamp:
01/12/2026 09:15:00 PM (8 months ago)
Author:
westonruter
Message:

Code Modernization: Utilize spaceship operator <=> in sort comparison logic.

Some replaced instances also fix a bug where the comparison function should have returned 0 as opposed to 1 or -1 as used in ternaries. This results in a performance improvement.

Developed in https://github.com/WordPress/wordpress-develop/pull/10717

Props soean, mukesh27, westonruter.
Fixes #64497.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-ms-themes-list-table.php

    r61444 r61474  
    303303                $b = $theme_b[ $orderby ];
    304304
    305                 if ( $a === $b ) {
    306                         return 0;
    307                 }
    308 
    309                 if ( 'DESC' === $order ) {
    310                         return ( $a < $b ) ? 1 : -1;
    311                 } else {
    312                         return ( $a < $b ) ? -1 : 1;
    313                 }
     305                return 'DESC' === $order ?
     306                        $b <=> $a :
     307                        $a <=> $b;
    314308        }
    315309
Note: See TracChangeset for help on using the changeset viewer.