JsonArray with capacity in constructor (#1033)
JsonArray with capacity in constructor
This commit is contained in:
parent
9e44d60b83
commit
fd37cf1d0d
@ -39,14 +39,21 @@ public final class JsonArray extends JsonElement implements Iterable<JsonElement
|
|||||||
public JsonArray() {
|
public JsonArray() {
|
||||||
elements = new ArrayList<JsonElement>();
|
elements = new ArrayList<JsonElement>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public JsonArray(int capacity) {
|
||||||
|
elements = new ArrayList<JsonElement>(capacity);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
JsonArray deepCopy() {
|
JsonArray deepCopy() {
|
||||||
JsonArray result = new JsonArray();
|
if (!elements.isEmpty()) {
|
||||||
for (JsonElement element : elements) {
|
JsonArray result = new JsonArray(elements.size());
|
||||||
result.add(element.deepCopy());
|
for (JsonElement element : elements) {
|
||||||
|
result.add(element.deepCopy());
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
return result;
|
return new JsonArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user