From 302071785a2828ffd6c39f76f7537bde5664a7b8 Mon Sep 17 00:00:00 2001 From: Vic Nightfall Date: Fri, 17 May 2024 12:04:27 +0200 Subject: [PATCH] use a map instead --- std/reflection.pr | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/std/reflection.pr b/std/reflection.pr index 986e860..76704f9 100644 --- a/std/reflection.pr +++ b/std/reflection.pr @@ -153,8 +153,6 @@ export type TupleT = &struct { elements: &[weak Type] } -var types: &[Type] - type TypeKind = enum { BOOL WORD @@ -175,13 +173,18 @@ type TypeKind = enum { } import io +import map + +var types: &Map(size_t, Type) // Type registry functions def load_types(data: [uint8], num: size_t, strings: *char) { let fp = io::open_memory_as_file(data, "r") defer close(fp) - types = allocate_ref(Type, num) + if not types { + types = map::make(size_t, Type) + } var index = 0 while index < num {