This is an automated email from the ASF dual-hosted git repository.

jgemignani pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/age.git


The following commit(s) were added to refs/heads/master by this push:
     new b0c9e9c0 Moved create_empty_agtype out of loops (#888)
b0c9e9c0 is described below

commit b0c9e9c09ba09db7cefeb848514cabc31f163bca
Author: mohayu22 <[email protected]>
AuthorDate: Thu May 4 00:24:55 2023 +0500

    Moved create_empty_agtype out of loops (#888)
    
    To avoid repeated calls inside the loop,
    "create_empty_agtype" was declared outside the loop
    and its output was assigned to the "props" variable
    which is then used inside the loop.
---
 src/backend/utils/graph_generation.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/backend/utils/graph_generation.c 
b/src/backend/utils/graph_generation.c
index e1a36344..466a8726 100644
--- a/src/backend/utils/graph_generation.c
+++ b/src/backend/utils/graph_generation.c
@@ -195,12 +195,13 @@ Datum create_complete_graph(PG_FUNCTION_ARGS)
     vtx_seq_id = get_relname_relid(vtx_seq_name_str, nsp_id);
     edge_seq_id = get_relname_relid(edge_seq_name_str, nsp_id);
 
+    props = create_empty_agtype();  
+  
     /* Creating vertices*/
     for (i=(int64)1;i<=no_vertices;i++)
     {   
         vid = nextval_internal(vtx_seq_id, true);
         object_graph_id = make_graphid(vtx_label_id, vid);
-        props = create_empty_agtype();
         insert_vertex_simple(graph_id,vtx_name_str,object_graph_id,props);
     }
 
@@ -218,9 +219,7 @@ Datum create_complete_graph(PG_FUNCTION_ARGS)
 
             start_vertex_graph_id = make_graphid(vtx_label_id, start_vid);
             end_vertex_graph_id = make_graphid(vtx_label_id, end_vid);
-
-            props = create_empty_agtype();
-
+          
             insert_edge_simple(graph_id, edge_name_str,
                             object_graph_id, start_vertex_graph_id,
                             end_vertex_graph_id, props);

Reply via email to