Fix compact() operation on NIO buffers

This commit is contained in:
Alexey Andreev 2017-11-02 23:30:03 +03:00
parent 389b55be91
commit 6145afcbf8
7 changed files with 14 additions and 14 deletions

View File

@ -90,15 +90,15 @@ class TByteBufferImpl extends TByteBuffer {
if (readOnly) {
throw new TReadOnlyBufferException();
}
int sz = remaining();
if (position > 0) {
int sz = remaining();
int dst = start;
int src = start + position;
for (int i = 0; i < sz; ++i) {
array[dst++] = array[src++];
}
position = sz;
}
position = sz;
limit = capacity;
mark = -1;
return this;

View File

@ -82,14 +82,14 @@ abstract class TCharBufferImpl extends TCharBuffer {
if (isReadOnly()) {
throw new TReadOnlyBufferException();
}
int sz = remaining();
if (position > 0) {
int sz = remaining();
int src = position;
for (int i = 0; i < sz; ++i) {
putChar(i, getChar(src++));
}
position = sz;
}
position = sz;
limit = capacity;
mark = -1;
return this;

View File

@ -82,14 +82,14 @@ abstract class TDoubleBufferImpl extends TDoubleBuffer {
if (isReadOnly()) {
throw new TReadOnlyBufferException();
}
int sz = remaining();
if (position > 0) {
int sz = remaining();
int src = position;
for (int i = 0; i < sz; ++i) {
putElement(i, getElement(src++));
}
position = sz;
}
position = sz;
limit = capacity;
mark = -1;
return this;

View File

@ -82,14 +82,14 @@ abstract class TFloatBufferImpl extends TFloatBuffer {
if (isReadOnly()) {
throw new TReadOnlyBufferException();
}
int sz = remaining();
if (position > 0) {
int sz = remaining();
int src = position;
for (int i = 0; i < sz; ++i) {
putElement(i, getElement(src++));
}
position = sz;
}
position = sz;
limit = capacity;
mark = -1;
return this;

View File

@ -82,14 +82,14 @@ abstract class TIntBufferImpl extends TIntBuffer {
if (isReadOnly()) {
throw new TReadOnlyBufferException();
}
int sz = remaining();
if (position > 0) {
int sz = remaining();
int src = position;
for (int i = 0; i < sz; ++i) {
putElement(i, getElement(src++));
}
position = sz;
}
position = sz;
limit = capacity;
mark = -1;
return this;

View File

@ -82,14 +82,14 @@ abstract class TLongBufferImpl extends TLongBuffer {
if (isReadOnly()) {
throw new TReadOnlyBufferException();
}
int sz = remaining();
if (position > 0) {
int sz = remaining();
int src = position;
for (int i = 0; i < sz; ++i) {
putElement(i, getElement(src++));
}
position = sz;
}
position = sz;
limit = capacity;
mark = -1;
return this;

View File

@ -82,14 +82,14 @@ abstract class TShortBufferImpl extends TShortBuffer {
if (isReadOnly()) {
throw new TReadOnlyBufferException();
}
int sz = remaining();
if (position > 0) {
int sz = remaining();
int src = position;
for (int i = 0; i < sz; ++i) {
putElement(i, getElement(src++));
}
position = sz;
}
position = sz;
limit = capacity;
mark = -1;
return this;