Skip to content

Commit

Permalink
Fix SUBSEQ and REVERSE on SIMPLE-VECTORS backed by NIO classes
Browse files Browse the repository at this point in the history
  • Loading branch information
easye committed Sep 11, 2023
1 parent 3cd1945 commit 4c3adfb
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/org/armedbear/lisp/BasicVectorBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -174,21 +174,21 @@ public void aset(int i, LispObject newValue) {

@Override
public LispObject subseq(int start, int end) {
int length = start - end;
int length = end - start;
try {
BasicVectorBuffer result = null;
switch (specializedOn) {
case U8:
result = new BasicVectorBuffer(ByteBuffer.class, length);
result = new BasicVectorBuffer(Byte.class, length);
break;
case U16:
result = new BasicVectorBuffer(ShortBuffer.class, length);
result = new BasicVectorBuffer(Short.class, length);
break;
case U32:
result = new BasicVectorBuffer(IntBuffer.class, length);
result = new BasicVectorBuffer(Integer.class, length);
break;
case U64:
result = new BasicVectorBuffer(LongBuffer.class, length);
result = new BasicVectorBuffer(Long.class, length);
break;
}
result.bytes.put(asByteArray(), start, length * specializedOn.totalBytes);
Expand Down Expand Up @@ -288,31 +288,31 @@ public LispObject reverse() {
int i, j;
switch (specializedOn) {
case U8:
result = new BasicVectorBuffer(ByteBuffer.class, capacity);
result = new BasicVectorBuffer(Byte.class, capacity);
ByteBuffer byteSource = bytes;
ByteBuffer byteDestination = result.bytes;
for (i = 0, j = capacity - 1; i < capacity; i++, j--) {
byteDestination.put(i, byteSource.get(j));
}
break;
case U16:
result = new BasicVectorBuffer(ShortBuffer.class, capacity);
result = new BasicVectorBuffer(Short.class, capacity);
ShortBuffer shortSource = (ShortBuffer)data;
ShortBuffer shortDestination = (ShortBuffer)result.data;
for (i = 0, j = capacity - 1; i < capacity; i++, j--) {
shortDestination.put(i, shortSource.get(j));
}
break;
case U32:
result = new BasicVectorBuffer(IntBuffer.class, capacity);
result = new BasicVectorBuffer(Integer.class, capacity);
IntBuffer intSource = (IntBuffer)data;
IntBuffer intDestination = (IntBuffer)result.data;
for (i = 0, j = capacity - 1; i < capacity; i++, j--) {
intDestination.put(i, intSource.get(j));
}
break;
case U64:
result = new BasicVectorBuffer(LongBuffer.class, capacity);
result = new BasicVectorBuffer(Long.class, capacity);
LongBuffer longSource = (LongBuffer)data;
LongBuffer longDestination = (LongBuffer)result.data;
for (i = 0, j = capacity - 1; i < capacity; i++, j--) {
Expand Down

0 comments on commit 4c3adfb

Please sign in to comment.