From 8fc01d4e1a717d148193d5cda476563b096aa6ac Mon Sep 17 00:00:00 2001 From: Christoffer Lerno Date: Mon, 2 Jun 2025 22:53:01 +0200 Subject: [PATCH] Simplify contract macros. --- lib/std/core/bitorder.c3 | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/lib/std/core/bitorder.c3 b/lib/std/core/bitorder.c3 index aac11326c..da6c06484 100644 --- a/lib/std/core/bitorder.c3 +++ b/lib/std/core/bitorder.c3 @@ -148,15 +148,13 @@ macro bool is_array_or_slice_of_char(bytes) { $switch @typekind(bytes): $case POINTER: - var $Inner = $typefrom($typeof(bytes).inner); - $if $Inner.kindof == ARRAY: - var $Inner2 = $typefrom($Inner.inner); - return $Inner2.typeid == char.typeid; + typeid $inner = $typeof(bytes).inner; + $if $inner.kindof == ARRAY: + return $inner.inner == char.typeid; $endif $case ARRAY: $case SLICE: - var $Inner = $typefrom($typeof(bytes).inner); - return $Inner.typeid == char.typeid; + return $typeof(bytes).inner == char.typeid; $default: return false; $endswitch @@ -166,14 +164,12 @@ macro bool is_arrayptr_or_slice_of_char(bytes) { $switch @typekind(bytes): $case POINTER: - var $Inner = $typefrom($typeof(bytes).inner); - $if $Inner.kindof == ARRAY: - var $Inner2 = $typefrom($Inner.inner); - return $Inner2.typeid == char.typeid; + var $inner = $typeof(bytes).inner; + $if $inner.kindof == ARRAY: + return $inner.inner == char.typeid; $endif $case SLICE: - var $Inner = $typefrom($typeof(bytes).inner); - return $Inner.typeid == char.typeid; + return $typeof(bytes).inner == char.typeid; $default: return false; $endswitch