[Jython-checkins] jython (merge 2.5 -> default): Merge 2.5.
frank.wierzbicki
jython-checkins at python.org
Fri Jul 13 20:08:43 CEST 2012
http://hg.python.org/jython/rev/b2725f5ff56b
changeset: 6791:b2725f5ff56b
parent: 6789:8b61a77d6dd0
parent: 6790:36e6f6a4f476
user: Frank Wierzbicki <fwierzbicki at gmail.com>
date: Fri Jul 13 09:25:08 2012 -0700
summary:
Merge 2.5.
files:
src/org/python/core/io/StreamIO.java | 52 +++++----------
1 files changed, 17 insertions(+), 35 deletions(-)
diff --git a/src/org/python/core/io/StreamIO.java b/src/org/python/core/io/StreamIO.java
--- a/src/org/python/core/io/StreamIO.java
+++ b/src/org/python/core/io/StreamIO.java
@@ -301,43 +301,25 @@
int len = dst.remaining();
int totalRead = 0;
int bytesRead = 0;
- if (dst.hasArray()) {
- while (totalRead < len) {
- // array() can throw RuntimeExceptions but really shouldn't when
- // hasArray() is true
- try {
- begin();
- bytesRead = in.read(dst.array(), dst.arrayOffset(), dst.remaining());
- } finally {
- end(bytesRead > 0);
- }
- if (bytesRead < 0) {
- break;
- } else {
- dst.position(dst.position() + bytesRead);
- totalRead += bytesRead;
- }
+
+ byte buf[] = new byte[0];
+ while (totalRead < len) {
+ int bytesToRead = Math.min((len - totalRead), CHUNK);
+ if (buf.length < bytesToRead) {
+ buf = new byte[bytesToRead];
}
- } else {
- byte buf[] = new byte[0];
- while (totalRead < len) {
- int bytesToRead = Math.min((len - totalRead), CHUNK);
- if (buf.length < bytesToRead) {
- buf = new byte[bytesToRead];
- }
- try {
- begin();
- bytesRead = in.read(buf, 0, bytesToRead);
- } finally {
- end(bytesRead > 0);
- }
- if (bytesRead < 0) {
- break;
- } else {
- totalRead += bytesRead;
- }
- dst.put(buf, 0, bytesRead);
+ try {
+ begin();
+ bytesRead = in.read(buf, 0, bytesToRead);
+ } finally {
+ end(bytesRead > 0);
}
+ if (bytesRead < 0) {
+ break;
+ } else {
+ totalRead += bytesRead;
+ }
+ dst.put(buf, 0, bytesRead);
}
if ((bytesRead < 0) && (totalRead == 0)) {
return -1;
--
Repository URL: http://hg.python.org/jython
More information about the Jython-checkins
mailing list