Skip to content

Commit

Permalink
More code tidying
Browse files Browse the repository at this point in the history
  • Loading branch information
mikera committed May 3, 2024
1 parent 76adc53 commit 85f361e
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 8 deletions.
8 changes: 3 additions & 5 deletions convex-core/src/main/java/convex/core/data/Vectors.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ public static <T extends ACell> AVector<T> wrap(ACell[] elements) {
*/
@SuppressWarnings("unchecked")
public static <R extends ACell, T extends ACell> AVector<R> create(Collection<?> elements) {
if (elements instanceof ASequence) return create((ASequence<R>) elements);
if (elements instanceof ASequence) return ((ASequence<R>) elements).toVector();
if (elements.size() == 0) return empty();
ACell[] cells=Cells.toCellArray(elements.toArray());
return (AVector<R>) create(cells);
return wrap(cells);
}

/**
Expand All @@ -102,11 +102,9 @@ public static <R extends ACell, T extends ACell> AVector<R> create(Collection<?>
@SuppressWarnings("unchecked")
public static <R extends ACell> AVector<R> create(ASequence<R> list) {
if (list instanceof AVector) return (AVector<R>) list.getCanonical();
if (list.size() == 0) return empty();
return create(list.toCellArray());
return wrap(list.toCellArray());
}


@SuppressWarnings("unchecked")
public static <T extends ACell> AVector<T> empty() {
return (VectorLeaf<T>) VectorLeaf.EMPTY;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public void testIntStream() throws InvalidDataException, ValidationException {

AVector<CVMLong> v2 = Vectors.create(list);
v2.validate();
assertEquals(v.getClass(), v2.getClass());
assertEquals(v, v2);

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.math.BigInteger;

Expand Down Expand Up @@ -269,7 +268,6 @@ private void assertParseError(String s) {
private void doRoundTripTest(String s) {
ACell a=Reader.read(s);
if (a!=null) {
assertTrue(a.isCanonical());
AString ps=a.print();
assertEquals(s,ps.toString());
assertEquals(Strings.create(s),ps);
Expand Down

0 comments on commit 85f361e

Please sign in to comment.