Simplify contract macros.

This commit is contained in:
Christoffer Lerno
2025-06-02 22:53:01 +02:00
parent a48e2274e5
commit 8fc01d4e1a

View File

@@ -148,15 +148,13 @@ macro bool is_array_or_slice_of_char(bytes)
{ {
$switch @typekind(bytes): $switch @typekind(bytes):
$case POINTER: $case POINTER:
var $Inner = $typefrom($typeof(bytes).inner); typeid $inner = $typeof(bytes).inner;
$if $Inner.kindof == ARRAY: $if $inner.kindof == ARRAY:
var $Inner2 = $typefrom($Inner.inner); return $inner.inner == char.typeid;
return $Inner2.typeid == char.typeid;
$endif $endif
$case ARRAY: $case ARRAY:
$case SLICE: $case SLICE:
var $Inner = $typefrom($typeof(bytes).inner); return $typeof(bytes).inner == char.typeid;
return $Inner.typeid == char.typeid;
$default: $default:
return false; return false;
$endswitch $endswitch
@@ -166,14 +164,12 @@ macro bool is_arrayptr_or_slice_of_char(bytes)
{ {
$switch @typekind(bytes): $switch @typekind(bytes):
$case POINTER: $case POINTER:
var $Inner = $typefrom($typeof(bytes).inner); var $inner = $typeof(bytes).inner;
$if $Inner.kindof == ARRAY: $if $inner.kindof == ARRAY:
var $Inner2 = $typefrom($Inner.inner); return $inner.inner == char.typeid;
return $Inner2.typeid == char.typeid;
$endif $endif
$case SLICE: $case SLICE:
var $Inner = $typefrom($typeof(bytes).inner); return $typeof(bytes).inner == char.typeid;
return $Inner.typeid == char.typeid;
$default: $default:
return false; return false;
$endswitch $endswitch