From 34abb3748b391146941fc0769f8291e136f7c018 Mon Sep 17 00:00:00 2001
From: Max Kellermann <mk@cm4all.com>
Date: Thu, 3 Feb 2022 22:57:53 +0100
Subject: [PATCH] pomo/streams: use stream_get_contents() in read_all()

stream_get_contents() is faster, because the PHP core can decide how
to best read the reamining file; it could decide to issue just one
read() call or mmap() the file first.

The old chunk size of 4 kB was rather clumsy, because it is smaller
than PHP's default stream buffer size of 8 kB.
---
 src/wp-includes/pomo/streams.php | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/src/wp-includes/pomo/streams.php b/src/wp-includes/pomo/streams.php
index e95dc17076..6a971af065 100644
--- a/src/wp-includes/pomo/streams.php
+++ b/src/wp-includes/pomo/streams.php
@@ -217,11 +217,7 @@ if ( ! class_exists( 'POMO_FileReader', false ) ) :
 		 * @return string
 		 */
 		public function read_all() {
-			$all = '';
-			while ( ! $this->feof() ) {
-				$all .= $this->read( 4096 );
-			}
-			return $all;
+			return stream_get_contents( $this->_f );
 		}
 	}
 endif;
-- 
2.34.0

