Skip to content

Commit 6808d5f

Browse files
committed
Misc code tidying
1 parent 802fdd1 commit 6808d5f

22 files changed

+44
-29
lines changed

convex-core/src/main/java/convex/core/cvm/State.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import convex.core.data.Index;
3333
import convex.core.data.Keyword;
3434
import convex.core.data.Keywords;
35-
import convex.core.data.LongBlob;
3635
import convex.core.data.MapEntry;
3736
import convex.core.data.PeerStatus;
3837
import convex.core.data.Ref;
@@ -41,6 +40,7 @@
4140
import convex.core.data.Symbol;
4241
import convex.core.data.Tag;
4342
import convex.core.data.Vectors;
43+
import convex.core.data.impl.LongBlob;
4444
import convex.core.data.prim.CVMLong;
4545
import convex.core.exceptions.BadFormatException;
4646
import convex.core.exceptions.InvalidDataException;

convex-core/src/main/java/convex/core/data/AArrayBlob.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,15 +216,15 @@ public int getHexDigit(long digitPos) {
216216
* Gets the internal array backing this Blob. Use with caution!
217217
* @return Byte array backing this blob
218218
*/
219-
public byte[] getInternalArray() {
219+
public final byte[] getInternalArray() {
220220
return store;
221221
}
222222

223223
/**
224224
* Gets this offset into the internal array backing this Blob.
225225
* @return Offset into backing array
226226
*/
227-
public int getInternalOffset() {
227+
public final int getInternalOffset() {
228228
return offset;
229229
}
230230

@@ -366,7 +366,7 @@ public int getRefCount() {
366366
}
367367

368368
@Override
369-
public int read(long offset, long count, ByteBuffer dest) {
369+
public int toByteBuffer(long offset, long count, ByteBuffer dest) {
370370
if (count<0) throw new IllegalArgumentException("Negative count");
371371
if ((offset<0)||(offset+count>this.count)) throw new IllegalArgumentException();
372372
int n=(int)count;

convex-core/src/main/java/convex/core/data/ABlob.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,6 @@ public byte byteAt(long i) {
168168
}
169169
return byteAtUnchecked(i);
170170
}
171-
172-
173171

174172
/**
175173
* Append an additional Blob to this, creating a new Blob as needed.
@@ -330,19 +328,19 @@ public short shortAt(long i) {
330328
* @param dest Destination byte buffer
331329
* @return Number of bytes read
332330
*/
333-
public int read(long offset, ByteBuffer dest) {
331+
public int toByteBuffer(long offset, ByteBuffer dest) {
334332
long n=Math.min(count()-offset, dest.remaining());
335-
return read(offset,n,dest);
333+
return toByteBuffer(offset,n,dest);
336334
}
337335

338336
/**
339337
* Gets bytes from this Blob into a ByteBuffer
340338
* @param offset Offset into this Blob to read from
341-
* @param count Number of bytes to read. Must be in bounds
339+
* @param count Number of bytes to read.
342340
* @param dest Destination byte buffer
343341
* @return Number of bytes read
344342
*/
345-
public abstract int read(long offset, long count, ByteBuffer dest);
343+
public abstract int toByteBuffer(long offset, long count, ByteBuffer dest);
346344

347345
/**
348346
* Replaces a slice of this Blob, returning a new Blob

convex-core/src/main/java/convex/core/data/ACell.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public abstract class ACell extends AObject implements IWriteable, IValidated {
2525
protected long memorySize=-1;
2626

2727
/**
28-
* Cached Ref. This is useful to manage persistence. Also cached Ref MUST refer to canonical value
28+
* Cached Ref. This is useful to manage persistence. Cached Ref MUST refer to a canonical value
2929
*/
3030
protected Ref<ACell> cachedRef=null;
3131

convex-core/src/main/java/convex/core/data/Address.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package convex.core.data;
22

3+
import convex.core.data.impl.LongBlob;
34
import convex.core.data.prim.CVMLong;
45
import convex.core.data.type.AType;
56
import convex.core.data.type.Types;

convex-core/src/main/java/convex/core/data/BlobTree.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ public ABlob toCanonical() {
599599
}
600600

601601
@Override
602-
public int read(long offset, long count, ByteBuffer dest) {
602+
public int toByteBuffer(long offset, long count, ByteBuffer dest) {
603603
if (count<0) throw new IllegalArgumentException("Negative count");
604604
if ((offset<0)||(offset+count>this.count)) throw new IndexOutOfBoundsException();
605605
int result=0;
@@ -610,7 +610,7 @@ public int read(long offset, long count, ByteBuffer dest) {
610610
if (offset<csize) {
611611
long n=Math.min(count, csize-offset);
612612
if (n>0) {
613-
result+=getChild(i).read(offset,n, dest);
613+
result+=getChild(i).toByteBuffer(offset,n, dest);
614614
}
615615
count-=n;
616616
offset=0; // offset is now the start of the next child

convex-core/src/main/java/convex/core/data/Format.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -854,8 +854,9 @@ public static <T extends ACell> T decodeMultiCell(Blob data) throws BadFormatExc
854854
ArrayList<ACell> stack=new ArrayList<>();
855855

856856
IRefFunction func=new IRefFunction() {
857+
@SuppressWarnings("rawtypes")
857858
@Override
858-
public Ref<?> apply(Ref<?> r) {
859+
public Ref apply(Ref r) {
859860
if (r.isEmbedded()) {
860861
ACell cc=r.getValue();
861862
if (cc==null) return r;

convex-core/src/main/java/convex/core/data/IRefFunction.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
* In general, IRefFunction is used to provide a visitor for data objects containing nested Refs.
88
*/
99
@FunctionalInterface
10-
public interface IRefFunction {
10+
public interface IRefFunction {
1111

1212
// Note we can't have a generic type parameter in a functional interface.
1313
// So using a wildcard seems the best option?
1414

15-
public Ref<?> apply(Ref<?> t);
15+
@SuppressWarnings("rawtypes")
16+
public Ref apply(Ref t);
1617
}

convex-core/src/main/java/convex/core/data/RefDirect.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ private RefDirect(T value, Hash hash, int flags) {
3232
* @param status Status for the Ref
3333
* @return New Direct Ref
3434
*/
35-
static <T extends ACell> RefDirect<T> create(T value, Hash hash, int status) {
35+
public static <T extends ACell> RefDirect<T> create(T value, Hash hash, int status) {
3636
int flags=status&Ref.STATUS_MASK;
3737
return new RefDirect<T>(value, hash, flags);
3838
}

convex-core/src/main/java/convex/core/data/StringSlice.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package convex.core.data;
22

3+
import convex.core.data.impl.LongBlob;
34
import convex.core.data.util.BlobBuilder;
45
import convex.core.exceptions.InvalidDataException;
56
import convex.core.util.Errors;

0 commit comments

Comments
 (0)