]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.graph.db/src/org/simantics/graph/db/TransferableGraphs.java
Fixed various bugs in TG readers
[simantics/platform.git] / bundles / org.simantics.graph.db / src / org / simantics / graph / db / TransferableGraphs.java
index 0841e1455569ed08e0f184c750c5125e9fe55aa3..2b93df74dceeb0fed0b3f0c871a62fe043968d8a 100644 (file)
@@ -597,15 +597,14 @@ public class TransferableGraphs {
 
        public static TransferableGraph1 create(ReadGraph graph, TransferableGraphSource source) throws DatabaseException {
                
-               final TIntArrayList statements = new TIntArrayList();
-               final ArrayList<Value> values = new ArrayList<>();
-               final ArrayList<Identity> identities = new ArrayList<>();
-               
                try {
 
+                       ArrayList<Identity> identities = new ArrayList<>(source.getIdentityCount());
+                       source.forIdentities(graph, i -> identities.add(i));
+                       TIntArrayList statements = new TIntArrayList(source.getStatementCount());
                        source.forStatements(graph, r -> statements.addAll(r));
+                       ArrayList<Value> values = new ArrayList<>(source.getValueCount());
                        source.forValues(graph, v -> values.add(v));
-                       source.forIdentities(graph, i -> identities.add(i));
 
                        return new TransferableGraph1(source.getResourceCount(), 
                                        identities.toArray(new Identity[identities.size()]),