From 2b5ba96a3995d488eb9180c7aea7b146ce7925e4 Mon Sep 17 00:00:00 2001 From: Anton Leherbauer Date: Fri, 16 Oct 2009 09:16:51 +0000 Subject: [PATCH] Minor performance optimization in SpawnerInputStream --- .../org/eclipse/cdt/utils/spawner/SpawnerInputStream.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/spawner/SpawnerInputStream.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/spawner/SpawnerInputStream.java index 3af47015351..408b50cd6bc 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/spawner/SpawnerInputStream.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/spawner/SpawnerInputStream.java @@ -61,13 +61,15 @@ class SpawnerInputStream extends InputStream { } else if (len == 0) { return 0; } - byte[] tmpBuf = new byte[len]; + byte[] tmpBuf = off > 0 ? new byte[len - off] : buf; len = read0(fd, tmpBuf, len); if (len <= 0) return -1; - System.arraycopy(tmpBuf, 0, buf, off, len); + if (tmpBuf != buf) { + System.arraycopy(tmpBuf, 0, buf, off, len); + } return len; }