Skip to content

Commit

Permalink
Update MutablePrimitiveArrayList.java.ftl
Browse files Browse the repository at this point in the history
  • Loading branch information
Glavo committed Jul 7, 2024
1 parent 99e37a1 commit b6fcc32
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,15 @@
import kala.collection.factory.primitive.BooleanCollectionFactory;
import kala.collection.immutable.primitive.ImmutableBooleanArray;
import kala.collection.primitive.*;
import kala.function.*;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.io.*;
import java.util.*;
import java.util.function.*;

public final class MutableBooleanArrayList extends AbstractMutableBooleanList implements IndexedBooleanSeq, Serializable {
@Serial
private static final long serialVersionUID = 2545219250020890853L;

private static final Factory FACTORY = new Factory();
Expand Down Expand Up @@ -589,6 +586,7 @@ public int copyToArray(int srcPos, boolean @NotNull [] dest, int destPos, int li

//region Serialization

@Serial
private void writeObject(ObjectOutputStream out) throws IOException {
out.writeInt(size);
for (int i = 0; i < size; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,12 @@ import kala.function.*;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.io.*;
import java.util.*;
import java.util.function.*;

public final class Mutable${Type}ArrayList extends AbstractMutable${Type}List implements Indexed${Type}Seq, Serializable {
@Serial
private static final long serialVersionUID = 2545219250020890853L;

private static final Factory FACTORY = new Factory();
Expand Down Expand Up @@ -156,7 +154,7 @@ public final class Mutable${Type}ArrayList extends AbstractMutable${Type}List im
public static @NotNull Mutable${Type}ArrayList from(@NotNull ${Type}Iterator it) {
Mutable${Type}ArrayList buffer = new Mutable${Type}ArrayList();
while (it.hasNext()) {
buffer.append(it.next());
buffer.append(it.next${Type}());
}
return buffer;
}
Expand Down Expand Up @@ -323,8 +321,7 @@ public final class Mutable${Type}ArrayList extends AbstractMutable${Type}List im
}

final int size = this.size;
if (values instanceof ${Type}SeqLike && ((${Type}SeqLike) values).supportsFastRandomAccess()) {
${Type}SeqLike seq = (${Type}SeqLike) values;
if (values instanceof ${Type}SeqLike seq && seq.supportsFastRandomAccess()) {
int s = seq.size();
if (s == 0) {
return;
Expand Down Expand Up @@ -533,12 +530,6 @@ public final class Mutable${Type}ArrayList extends AbstractMutable${Type}List im

int tailElementsCount = size - endIndex;
System.arraycopy(elements, endIndex, elements, beginIndex, tailElementsCount);
/*
if (tailElementsCount < rangeLength) {
Arrays.fill(elements, beginIndex + tailElementsCount, beginIndex + rangeLength, 0);
}
*/

this.size = size - rangeLength;
}

Expand Down Expand Up @@ -608,13 +599,15 @@ public final class Mutable${Type}ArrayList extends AbstractMutable${Type}List im

//region Serialization

@Serial
private void writeObject(ObjectOutputStream out) throws IOException {
out.writeInt(size);
for (int i = 0; i < size; i++) {
out.write${Type}(elements[i]);
}
}

@Serial
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
final int size = in.readInt();
final ${PrimitiveType}[] elements = size == 0 ? DEFAULT_EMPTY_ARRAY : new ${PrimitiveType}[Integer.max(DEFAULT_CAPACITY, size)];
Expand Down

0 comments on commit b6fcc32

Please sign in to comment.