Skip to content

Commit 58f5e6f

Browse files
committed
inline funcs
1 parent e558625 commit 58f5e6f

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/libasr/codegen/asr_to_c_cpp.h

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,9 @@ class CCPPList {
193193
std::string tab(indentation_spaces, ' ');
194194
std::string list_init_func = global_scope->get_unique_name("list_init_" + list_type_code);
195195
typecode2listfuncs[list_type_code]["list_init"] = list_init_func;
196-
std::string signature = indent + "void " + list_init_func + "(" + list_struct_type + "* x, int32_t capacity)";
197-
list_func_decls += signature + ";\n";
196+
std::string signature = "void " + list_init_func + "(" + list_struct_type + "* x, int32_t capacity)";
197+
list_func_decls += indent + "inline " + signature + ";\n";
198+
signature = indent + signature;
198199
generated_code += indent + signature + " {\n";
199200
generated_code += indent + tab + "x->capacity = capacity;\n";
200201
generated_code += indent + tab + "x->current_end_point = 0;\n";
@@ -213,7 +214,7 @@ class CCPPList {
213214
std::string signature = "void " + list_dc_func + "("
214215
+ list_struct_type + "* src, "
215216
+ list_struct_type + "* dest)";
216-
list_func_decls += signature + ";\n";
217+
list_func_decls += "inline " + signature + ";\n";
217218
generated_code += indent + signature + " {\n";
218219
generated_code += indent + tab + "dest->capacity = src->capacity;\n";
219220
generated_code += indent + tab + "dest->current_end_point = src->current_end_point;\n";
@@ -231,8 +232,9 @@ class CCPPList {
231232
std::string tab(indentation_spaces, ' ');
232233
std::string list_resize_func = global_scope->get_unique_name("resize_if_needed_" + list_type_code);
233234
typecode2listfuncs[list_type_code]["list_resize"] = list_resize_func;
234-
std::string signature = indent + "void " + list_resize_func + "(" + list_struct_type + "* x)";
235-
list_func_decls += signature + ";\n";
235+
std::string signature = "void " + list_resize_func + "(" + list_struct_type + "* x)";
236+
list_func_decls += indent + "inline " + signature + ";\n";
237+
signature = indent + signature;
236238
generated_code += indent + signature + " {\n";
237239
generated_code += indent + tab + "if (x->capacity == x->current_end_point) {\n";
238240
generated_code += indent + tab + tab + "x->capacity = 2 * x->capacity + 1;\n";
@@ -252,7 +254,7 @@ class CCPPList {
252254
std::string signature = "void " + list_append_func + "("
253255
+ list_struct_type + "* x, "
254256
+ list_element_type + " element)";
255-
list_func_decls += signature + ";\n";
257+
list_func_decls += "inline " + signature + ";\n";
256258
generated_code += indent + signature + " {\n";
257259
std::string list_resize_func = get_list_resize_func(list_type_code);
258260
generated_code += indent + tab + list_resize_func + "(x);\n";
@@ -275,7 +277,7 @@ class CCPPList {
275277
+ list_struct_type + "* x, "
276278
+ "int pos, "
277279
+ list_element_type + " element)";
278-
list_func_decls += signature + ";\n";
280+
list_func_decls += "inline " + signature + ";\n";
279281
generated_code += indent + signature + " {\n";
280282
std::string list_resize_func = get_list_resize_func(list_type_code);
281283
generated_code += indent + tab + list_resize_func + "(x);\n";
@@ -308,7 +310,7 @@ class CCPPList {
308310
std::string signature = "int " + list_find_item_pos_func + "("
309311
+ list_struct_type + "* x, "
310312
+ list_element_type + " element)";
311-
list_func_decls += signature + ";\n";
313+
list_func_decls += "inline " + signature + ";\n";
312314
generated_code += indent + signature + " {\n";
313315
generated_code += indent + tab + "int el_pos = 0;\n";
314316
generated_code += indent + tab + "while(x->current_end_point > el_pos) {;\n";
@@ -329,7 +331,7 @@ class CCPPList {
329331
std::string signature = "void " + list_remove_func + "("
330332
+ list_struct_type + "* x, "
331333
+ list_element_type + " element)";
332-
list_func_decls += signature + ";\n";
334+
list_func_decls += "inline " + signature + ";\n";
333335
generated_code += indent + signature + " {\n";
334336
std::string find_item_pos_func = get_list_find_item_position_function(list_type_code);
335337
generated_code += indent + tab + "int el_pos = " + find_item_pos_func + "(x, element);\n";

0 commit comments

Comments
 (0)