Skip to content

Commit 8a07180

Browse files
committed
refactor: Standardize object allocation to rb_class_new_instance
Replaced rb_funcall(..., "allocate", 0) with rb_class_new_instance(0, NULL, ...) in all TableFunction callbacks for consistency. Changed: - init_callback: InitInfo allocation - execute_callback: FunctionInfo and DataChunk allocation This matches the pattern already used in bind_callback and data_chunk.get_vector. Benefits: - More direct and efficient (no method lookup) - Consistent across all wrapper object creation - Standard Ruby C extension pattern Addresses CodeRabbit review feedback on PR #1103.
1 parent c445619 commit 8a07180

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

ext/duckdb/table_function.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ static void table_function_init_callback(duckdb_init_info info) {
268268
TypedData_Get_Struct(self, rubyDuckDBTableFunction, &table_function_data_type, ctx);
269269

270270
// Create InitInfo wrapper
271-
init_info_obj = rb_funcall(cDuckDBInitInfo, rb_intern("allocate"), 0);
271+
init_info_obj = rb_class_new_instance(0, NULL, cDuckDBInitInfo);
272272
init_info_ctx = get_struct_init_info(init_info_obj);
273273
init_info_ctx->info = info;
274274

@@ -330,12 +330,12 @@ static void table_function_execute_callback(duckdb_function_info info, duckdb_da
330330
TypedData_Get_Struct(self, rubyDuckDBTableFunction, &table_function_data_type, ctx);
331331

332332
// Create FunctionInfo wrapper
333-
func_info_obj = rb_funcall(cDuckDBFunctionInfo, rb_intern("allocate"), 0);
333+
func_info_obj = rb_class_new_instance(0, NULL, cDuckDBFunctionInfo);
334334
func_info_ctx = get_struct_function_info(func_info_obj);
335335
func_info_ctx->info = info;
336336

337337
// Create DataChunk wrapper
338-
data_chunk_obj = rb_funcall(cDuckDBDataChunk, rb_intern("allocate"), 0);
338+
data_chunk_obj = rb_class_new_instance(0, NULL, cDuckDBDataChunk);
339339
data_chunk_ctx = get_struct_data_chunk(data_chunk_obj);
340340
data_chunk_ctx->data_chunk = output;
341341

0 commit comments

Comments
 (0)