[wp-trac] [WordPress Trac] #55069: Optimize POMO_FileReader.read_all() using stream_get_contents()

WordPress Trac noreply at wordpress.org
Sat Feb 12 13:12:37 UTC 2022


#55069: Optimize POMO_FileReader.read_all() using stream_get_contents()
---------------------------+-----------------------------
 Reporter:  maxkellermann  |       Owner:  SergeyBiryukov
     Type:  enhancement    |      Status:  accepted
 Priority:  normal         |   Milestone:  6.0
Component:  I18N           |     Version:
 Severity:  normal         |  Resolution:
 Keywords:  has-patch      |     Focuses:  performance
---------------------------+-----------------------------

Comment (by SergeyBiryukov):

 In [changeset:"52718" 52718]:
 {{{
 #!CommitTicketReference repository="" revision="52718"
 Code Modernization: Use `file_get_contents()` in `wp_get_webp_info()`.

 `file_get_contents()` is faster than `fread()`, because the PHP core can
 decide how to best read the remaining file; it could decide to issue just
 one `read()` call or `mmap()` the file first.

 Per the PHP manual, `file_get_contents()` or `stream_get_contents()` is
 the preferred way to read the contents of a file into a string. It will
 use memory mapping techniques if supported by the OS to enhance
 performance.

 Reference: [https://www.php.net/manual/en/function.file-get-contents.php
 PHP Manual: file_get_contents()].

 Follow-up to [50810], [52696], [52698], [52701].

 Props maxkellermann.
 See #55069.
 }}}

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


More information about the wp-trac mailing list