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

WordPress Trac noreply at wordpress.org
Fri Feb 11 15:48:58 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:"52701" 52701]:
 {{{
 #!CommitTicketReference repository="" revision="52701"
 Code Modernization: Use `file_get_contents()` in `wp_get_image_mime()`.

 `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].

 Props maxkellermann.
 See #55069.
 }}}

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


More information about the wp-trac mailing list