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

WordPress Trac noreply at wordpress.org
Wed Feb 9 12:31:42 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:"52696" 52696]:
 {{{
 #!CommitTicketReference repository="" revision="52696"
 Code Modernization: Use `stream_get_contents()` in
 `POMO_FileReader::read_all()`.

 `stream_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 [12174].

 Props maxkellermann.
 See #55069.
 }}}

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


More information about the wp-trac mailing list