Skip to content
This repository was archived by the owner on Sep 20, 2021. It is now read-only.

Commit 29bec0a

Browse files
committed
readAll() has better performances.
1 parent e9cb03b commit 29bec0a

File tree

2 files changed

+2
-28
lines changed

2 files changed

+2
-28
lines changed

Read.php

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -187,20 +187,7 @@ public function readLine ( ) {
187187
*/
188188
public function readAll ( ) {
189189

190-
$current = $this->tell();
191-
192-
$this->seek(0, \Hoa\Stream\IStream\Pointable::SEEK_END);
193-
$end = $this->tell();
194-
195-
if(0 === $end)
196-
return '';
197-
198-
$this->seek(0, \Hoa\Stream\IStream\Pointable::SEEK_SET);
199-
$handle = $this->read($end);
200-
201-
$this->seek($current, \Hoa\Stream\IStream\Pointable::SEEK_SET);
202-
203-
return $handle;
190+
return stream_get_contents($this->getStream());
204191
}
205192

206193
/**

ReadWrite.php

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -195,20 +195,7 @@ public function readLine ( ) {
195195
*/
196196
public function readAll ( ) {
197197

198-
$current = $this->tell();
199-
200-
$this->seek(0, \Hoa\Stream\IStream\Pointable::SEEK_END);
201-
$end = $this->tell();
202-
203-
if(0 === $end)
204-
return '';
205-
206-
$this->seek(0, \Hoa\Stream\IStream\Pointable::SEEK_SET);
207-
$handle = $this->read($end);
208-
209-
$this->seek($current, \Hoa\Stream\IStream\Pointable::SEEK_SET);
210-
211-
return $handle;
198+
return stream_get_contents($this->getStream());
212199
}
213200

214201
/**

0 commit comments

Comments
 (0)