Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2011-02-23 06:57:14 +0000
committerEike Stepper2011-02-23 06:57:14 +0000
commitf34e7ffe61c2b210e48dd8ea18024aec791aac6c (patch)
treea436c8dc426ea40e6325d67d20664f8ce218aac9 /plugins/org.eclipse.net4j/src
parent7f455050757f0dff0f5169f658e6f818a78f43bf (diff)
downloadcdo-f34e7ffe61c2b210e48dd8ea18024aec791aac6c.tar.gz
cdo-f34e7ffe61c2b210e48dd8ea18024aec791aac6c.tar.xz
cdo-f34e7ffe61c2b210e48dd8ea18024aec791aac6c.zip
[337447] Optimize calls to TRACER in BufferOutputStream
https://bugs.eclipse.org/bugs/show_bug.cgi?id=337447
Diffstat (limited to 'plugins/org.eclipse.net4j/src')
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/buffer/BufferOutputStream.java38
1 files changed, 24 insertions, 14 deletions
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/buffer/BufferOutputStream.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/buffer/BufferOutputStream.java
index 7b6215929d..2b5325db68 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/buffer/BufferOutputStream.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/buffer/BufferOutputStream.java
@@ -99,7 +99,7 @@ public class BufferOutputStream extends OutputStream
{
throwExceptionOnError();
flushIfFilled();
- ensureBuffer();
+ ensureBufferPrivate();
// If this was called with a primitive byte with a negative value,
// the implicit conversion prepended 24 leading 1's. We'll undo those.
@@ -116,29 +116,34 @@ public class BufferOutputStream extends OutputStream
}
/**
- * Flushes the current buffer if it has no remaining space.
+ * Flushes the current buffer, it's handled over to the buffer handler.
*
* @throws IOException
* Signals that an I/O exception has occurred.
+ * @see #currentBuffer
+ * @see IBufferHandler#handleBuffer(IBuffer)
*/
- private void flushIfFilled() throws IOException
+ @Override
+ public void flush() throws IOException
{
- if (currentBuffer != null && !currentBuffer.getByteBuffer().hasRemaining())
- {
- flush();
- }
+ flushPrivate();
}
/**
- * Flushes the current buffer, it's handled over to the buffer handler.
+ * Flushes the current buffer if it has no remaining space.
*
* @throws IOException
* Signals that an I/O exception has occurred.
- * @see #currentBuffer
- * @see IBufferHandler#handleBuffer(IBuffer)
*/
- @Override
- public void flush() throws IOException
+ private void flushIfFilled() throws IOException
+ {
+ if (currentBuffer != null && !currentBuffer.getByteBuffer().hasRemaining())
+ {
+ flushPrivate();
+ }
+ }
+
+ private void flushPrivate()
{
if (currentBuffer != null)
{
@@ -150,9 +155,9 @@ public class BufferOutputStream extends OutputStream
public void flushWithEOS() throws IOException
{
throwExceptionOnError();
- ensureBuffer();
+ ensureBufferPrivate();
currentBuffer.setEOS(true);
- flush();
+ flushPrivate();
}
@Override
@@ -191,6 +196,11 @@ public class BufferOutputStream extends OutputStream
*/
protected void ensureBuffer() throws IOException
{
+ ensureBufferPrivate();
+ }
+
+ private void ensureBufferPrivate()
+ {
if (currentBuffer == null)
{
currentBuffer = bufferProvider.provideBuffer();

Back to the top