[wp-trac] [WordPress Trac] #12375: HTTP class contains redundant defined() check
WordPress Trac
wp-trac at lists.automattic.com
Thu Feb 25 17:11:02 UTC 2010
#12375: HTTP class contains redundant defined() check
-------------------------+--------------------------------------------------
Reporter: TobiasBg | Owner: dd32
Type: enhancement | Status: new
Priority: normal | Milestone: 3.0
Component: HTTP | Version:
Severity: normal | Keywords: has-patch commit
-------------------------+--------------------------------------------------
Line [http://core.trac.wordpress.org/browser/trunk/wp-includes/class-
http.php#L554 554 of wp-includes/class-http.php] contains a somewhat
redundant logic:
{{{
if ( ! defined('WP_HTTP_BLOCK_EXTERNAL') || (
defined('WP_HTTP_BLOCK_EXTERNAL') && WP_HTTP_BLOCK_EXTERNAL == false ) )
}}}
The part after the || will only be executed if the constant is defined,
thus it's overhead to check that again. Also checking constants for false
(like WP_HTTP_BLOCK_EXTERNAL == false) is not good practice.
I have attached two patches, one that simply removes the redundant check
and simplifies the WP_HTTP_BLOCK_EXTERNAL == false to !
WP_HTTP_BLOCK_EXTERNAL.
The second patch has the same logic, but has
[http://en.wikipedia.org/wiki/De_Morgan%27s_laws De Morgan's laws]
applied. I could decide what looks better :-)
--
Ticket URL: <http://core.trac.wordpress.org/ticket/12375>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list