General: Remove a few `is_object()` checks followed by `instanceof` operator.

This is a minor performance enhancement:

* If an object is passed, the call to `is_object()` will be redundant.
* If a non-object is passed, the `instanceof` operator (a variant of `is_a()`) will first [https://github.com/php/php-src/blob/f42992f/Zend/zend_builtin_functions.c#L630-L631 check if it is an object] before doing any further processing.

Therefore, no additional processing cycles should be wasted in both cases.

Follow-up to [6779], [48798], [48905], [49194], [55748].

Props Presskopp, costdev.
Fixes #58309.
Built from https://develop.svn.wordpress.org/trunk@55757


git-svn-id: http://core.svn.wordpress.org/trunk@55269 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2023-05-15 10:28:23 +00:00
parent c26ddc3eae
commit fe928b2e9a
3 changed files with 9 additions and 9 deletions

View File

@ -1170,8 +1170,8 @@
// ----- Reset the error handler
$this->privErrorReset();
// ----- Look if the $p_archive is a PclZip object
if (is_object($p_archive) && $p_archive instanceof pclzip)
// ----- Look if the $p_archive is an instantiated PclZip object
if ($p_archive instanceof pclzip)
{
// ----- Duplicate the archive
@ -1234,8 +1234,8 @@
return(0);
}
// ----- Look if the $p_archive_to_add is a PclZip object
if (is_object($p_archive_to_add) && $p_archive_to_add instanceof pclzip)
// ----- Look if the $p_archive_to_add is an instantiated PclZip object
if ($p_archive_to_add instanceof pclzip)
{
// ----- Merge the archive

View File

@ -3748,8 +3748,8 @@ function get_taxonomies_for_attachments( $output = 'names' ) {
* Determines whether the value is an acceptable type for GD image functions.
*
* In PHP 8.0, the GD extension uses GdImage objects for its data structures.
* This function checks if the passed value is either a resource of type `gd`
* or a GdImage object instance. Any other type will return false.
* This function checks if the passed value is either a GdImage object instance
* or a resource of type `gd`. Any other type will return false.
*
* @since 5.6.0
*
@ -3758,8 +3758,8 @@ function get_taxonomies_for_attachments( $output = 'names' ) {
* false otherwise.
*/
function is_gd_image( $image ) {
if ( is_resource( $image ) && 'gd' === get_resource_type( $image )
|| is_object( $image ) && $image instanceof GdImage
if ( $image instanceof GdImage
|| is_resource( $image ) && 'gd' === get_resource_type( $image )
) {
return true;
}

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.3-alpha-55756';
$wp_version = '6.3-alpha-55757';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.