From 146d3542d5f626099f4c30a0190b6e1d963e70f4 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sun, 17 Mar 2024 21:58:31 -0400 Subject: Don't bother comparing empty structs --- structs.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'structs.c') diff --git a/structs.c b/structs.c index 725eaac5..90aef9bb 100644 --- a/structs.c +++ b/structs.c @@ -152,8 +152,12 @@ void compile_struct_def(env_t *env, ast_t *ast) CORD typeinfo = CORD_asprintf("public const TypeInfo %r = {%zu, %zu, {.tag=CustomInfo, .CustomInfo={", full_name, type_size(t), type_align(t)); - typeinfo = CORD_all(typeinfo, ".as_text=(void*)", full_name, "$as_text, .compare=(void*)", full_name, "$compare, "); - env->code->funcs = CORD_all(env->code->funcs, compile_str_method(env, ast), compile_compare_method(env, ast)); + typeinfo = CORD_all(typeinfo, ".as_text=(void*)", full_name, "$as_text, "); + env->code->funcs = CORD_all(env->code->funcs, compile_str_method(env, ast)); + if (t->tag != StructType || Match(t, StructType)->fields) { + typeinfo = CORD_all(typeinfo, ".compare=(void*)", full_name, "$compare, "); + env->code->funcs = CORD_all(env->code->funcs, compile_compare_method(env, ast)); + } if (!t || !is_plain_data(env, t)) { env->code->funcs = CORD_all( env->code->funcs, compile_equals_method(env, ast), -- cgit v1.2.3