[wp-trac] [WordPress Trac] #48082: Replace `dirname(__FILE__)` with `__DIR__` (Performance improvement, massive patch)

WordPress Trac noreply at wordpress.org
Thu Feb 6 03:25:05 UTC 2020


#48082: Replace `dirname(__FILE__)` with `__DIR__` (Performance improvement,
massive patch)
------------------------------+--------------------------------------------
 Reporter:  ayeshrajans       |       Owner:  SergeyBiryukov
     Type:  enhancement       |      Status:  reviewing
 Priority:  normal            |   Milestone:  5.4
Component:  General           |     Version:
 Severity:  minor             |  Resolution:
 Keywords:  has-patch needs-  |     Focuses:  performance, coding-standards
  testing                     |
------------------------------+--------------------------------------------
Changes (by SergeyBiryukov):

 * owner:  (none) => SergeyBiryukov
 * status:  new => reviewing


Comment:

 It's worth mentioning that [https://stackoverflow.com/questions/186338
 /why-is-require-once-so-bad-to-use `require_once` is slower than
 `require`] due to an additional check whether the file has already been
 included, see the previous discussion on #20298 for more details.

 It probably won't make a big difference here, since most of the existing
 `admin-header.php` and `admin-footer.php` inclusions already use
 `require_once`, so I guess switching the remaining few to `require_once`
 makes sense from a consistency point of view, as long as the same file is
 not included a significant amount of times in a loop, or something like
 that. Still, since performance is one of the considerations with changes
 like this, I thought I'd mention this.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/48082#comment:12>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list