Make WordPress Core


Ignore:
Timestamp:
01/12/2026 09:15:00 PM (5 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-plugin-install-list-table.php

    r61456 r61474  
    459459        $b = $plugin_b->$orderby;
    460460
    461         if ( $a === $b ) {
    462             return 0;
    463         }
    464 
    465         if ( 'DESC' === $this->order ) {
    466             return ( $a < $b ) ? 1 : -1;
    467         } else {
    468             return ( $a < $b ) ? -1 : 1;
    469         }
     461        return 'DESC' === $this->order ?
     462            $b <=> $a :
     463            $a <=> $b;
    470464    }
    471465
Note: See TracChangeset for help on using the changeset viewer.