diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2009-01-15 16:12:07 -0800 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-01-15 16:12:07 -0800 |
commit | d94c06c605baa7814b787bab7c993775b486ffba (patch) | |
tree | a2b36c743db7cb9fd4d6ac4cc89fdfb53ed2e35e /nio/src | |
parent | a0881d052ee72e3f7e773374e9b1aa75fbd6be4c (diff) | |
download | libcore-d94c06c605baa7814b787bab7c993775b486ffba.zip libcore-d94c06c605baa7814b787bab7c993775b486ffba.tar.gz libcore-d94c06c605baa7814b787bab7c993775b486ffba.tar.bz2 |
auto import from //branches/cupcake/...@126645
Diffstat (limited to 'nio/src')
-rw-r--r-- | nio/src/main/java/java/nio/Buffer.java | 12 | ||||
-rw-r--r-- | nio/src/main/java/java/nio/IntToByteBufferAdapter.java | 11 | ||||
-rw-r--r-- | nio/src/main/java/java/nio/ShortToByteBufferAdapter.java | 11 |
3 files changed, 7 insertions, 27 deletions
diff --git a/nio/src/main/java/java/nio/Buffer.java b/nio/src/main/java/java/nio/Buffer.java index 844d2ce..9e870e4 100644 --- a/nio/src/main/java/java/nio/Buffer.java +++ b/nio/src/main/java/java/nio/Buffer.java @@ -150,21 +150,11 @@ public abstract class Buffer { * @since Android 1.0 */ public final Buffer clear() { - // BEGIN android-changed - internalClear(); - // END android-changed - return this; - } - - // BEGIN android-added - // We need a possibility to change the behavior of clear in some optimized - // DirectByteBuffer adapters. - void internalClear() { position = 0; mark = UNSET_MARK; limit = capacity; + return this; } - // END android-added /** * Flips this buffer. diff --git a/nio/src/main/java/java/nio/IntToByteBufferAdapter.java b/nio/src/main/java/java/nio/IntToByteBufferAdapter.java index e52f6b6..91b9311 100644 --- a/nio/src/main/java/java/nio/IntToByteBufferAdapter.java +++ b/nio/src/main/java/java/nio/IntToByteBufferAdapter.java @@ -194,8 +194,11 @@ final class IntToByteBufferAdapter extends IntBuffer implements DirectBuffer { } // BEGIN android-added + @Override public IntBuffer put(int[] i, int off, int len) { if (byteBuffer instanceof ReadWriteDirectByteBuffer) { + byteBuffer.limit(limit << 2); + byteBuffer.position(position << 2); ((ReadWriteDirectByteBuffer) byteBuffer).put(i, off, len); this.position += len; return this; @@ -203,14 +206,6 @@ final class IntToByteBufferAdapter extends IntBuffer implements DirectBuffer { return super.put(i, off, len); } } - - @Override - void internalClear() { - if (byteBuffer instanceof ReadWriteDirectByteBuffer) { - byteBuffer.clear(); - } - super.internalClear(); - } // END android-added public IntBuffer slice() { diff --git a/nio/src/main/java/java/nio/ShortToByteBufferAdapter.java b/nio/src/main/java/java/nio/ShortToByteBufferAdapter.java index fe4fff4..41ce50c 100644 --- a/nio/src/main/java/java/nio/ShortToByteBufferAdapter.java +++ b/nio/src/main/java/java/nio/ShortToByteBufferAdapter.java @@ -194,8 +194,11 @@ final class ShortToByteBufferAdapter extends ShortBuffer implements DirectBuffer } // BEGIN android-added + @Override public ShortBuffer put(short[] s, int off, int len) { if (byteBuffer instanceof ReadWriteDirectByteBuffer) { + byteBuffer.limit(limit << 1); + byteBuffer.position(position << 1); ((ReadWriteDirectByteBuffer) byteBuffer).put(s, off, len); this.position += len; return this; @@ -203,14 +206,6 @@ final class ShortToByteBufferAdapter extends ShortBuffer implements DirectBuffer return super.put(s, off, len); } } - - @Override - void internalClear() { - if (byteBuffer instanceof ReadWriteDirectByteBuffer) { - byteBuffer.clear(); - } - super.internalClear(); - } // END android-added public ShortBuffer slice() { |