[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Help-smalltalk] [PATCH 2/2] optimize FileStream>>#nextAvailable:... to
From: |
Paolo Bonzini |
Subject: |
[Help-smalltalk] [PATCH 2/2] optimize FileStream>>#nextAvailable:... to skip buffer. |
Date: |
Sat, 4 May 2013 18:26:45 +0200 |
2013-05-04 Paolo Bonzini <address@hidden>
* kernel/FileStream.st: Skip the buffer in #nextAvailable:... if
it is empty.
---
kernel/FileStream.st | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/kernel/FileStream.st b/kernel/FileStream.st
index 0c66169..255f76d 100644
--- a/kernel/FileStream.st
+++ b/kernel/FileStream.st
@@ -499,7 +499,10 @@ file object, such as /dev/rmt0 on UNIX or MTA0: on VMS).'>
<category: 'buffering'>
| last n |
writePtr notNil ifTrue: [self flush].
- ptr > endPtr ifTrue: [self fill].
+ ptr > endPtr ifTrue: [
+ anInteger > collection size
+ ifTrue: [^super nextAvailable: anInteger putAllOn: aStream].
+ self fill].
"Fetch data from the buffer, without doing more than one I/O operation."
last := endPtr min: ptr + anInteger - 1.
@@ -516,7 +519,10 @@ file object, such as /dev/rmt0 on UNIX or MTA0: on VMS).'>
<category: 'buffering'>
| last n |
writePtr notNil ifTrue: [self flush].
- ptr > endPtr ifTrue: [self fill].
+ ptr > endPtr ifTrue: [
+ anInteger > collection size
+ ifTrue: [^super nextAvailable: anInteger into: aCollection
startingAt: pos].
+ self fill].
"Fetch data from the buffer, without doing more than one I/O operation."
last := endPtr min: ptr + anInteger - 1.
--
1.8.2