From e9f29220416c946c183e3a6fda9afdd55c4bd841 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Christophe=20Beaupr=C3=A9?= Date: Sat, 20 Dec 2014 17:43:30 -0500 Subject: [PATCH] neo4j/graph: Enlarge in advance when loading from JSON. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jean-Christophe Beaupré --- lib/neo4j/graph/json_graph_store.nit | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/neo4j/graph/json_graph_store.nit b/lib/neo4j/graph/json_graph_store.nit index 20736ad..9c97216 100644 --- a/lib/neo4j/graph/json_graph_store.nit +++ b/lib/neo4j/graph/json_graph_store.nit @@ -168,6 +168,8 @@ redef class NeoGraph # For the expected format, see `JsonGraphStore`. fun load_json_object(o: JsonObject) do var json_nodes = o["nodes"].as(JsonArray) + var nodes = self.nodes + nodes.enlarge(nodes.length) for json_node in json_nodes do assert json_node isa JsonObject var node = new NeoNode.from_json_object(json_node) @@ -175,6 +177,8 @@ redef class NeoGraph end var json_edges = o["edges"].as(JsonArray) + var edges = self.edges + if edges isa AbstractArray[NeoEdge] then edges.enlarge(edges.length) for json_edge in json_edges do assert json_edge isa JsonObject var from = nodes[nodes.id_from_jsonable(json_edge["from"])] -- 1.7.9.5