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. Built from https://develop.svn.wordpress.org/trunk@52696 git-svn-id: http://core.svn.wordpress.org/trunk@52285 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
f76b77b7c3
commit
4f856dfae0
|
@ -217,11 +217,7 @@ if ( ! class_exists( 'POMO_FileReader', false ) ) :
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function read_all() {
|
public function read_all() {
|
||||||
$all = '';
|
return stream_get_contents( $this->_f );
|
||||||
while ( ! $this->feof() ) {
|
|
||||||
$all .= $this->read( 4096 );
|
|
||||||
}
|
|
||||||
return $all;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
endif;
|
endif;
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '6.0-alpha-52695';
|
$wp_version = '6.0-alpha-52696';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue