mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
Inline are_types_identical_unique_tuples to improve odin_doc_type performance
This commit is contained in:
+36
-5
@@ -471,6 +471,8 @@ gb_internal OdinDocArray<OdinDocEntityIndex> odin_doc_add_entity_as_slice(OdinDo
|
|||||||
return odin_write_item_as_slice(w, index);
|
return odin_write_item_as_slice(w, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
gb_internal OdinDocTypeIndex odin_doc_type(OdinDocWriter *w, Type *type) {
|
gb_internal OdinDocTypeIndex odin_doc_type(OdinDocWriter *w, Type *type) {
|
||||||
if (type == nullptr) {
|
if (type == nullptr) {
|
||||||
return 0;
|
return 0;
|
||||||
@@ -481,12 +483,41 @@ gb_internal OdinDocTypeIndex odin_doc_type(OdinDocWriter *w, Type *type) {
|
|||||||
}
|
}
|
||||||
for (auto const &entry : w->type_cache) {
|
for (auto const &entry : w->type_cache) {
|
||||||
// NOTE(bill): THIS IS SLOW
|
// NOTE(bill): THIS IS SLOW
|
||||||
Type *other = entry.key;
|
Type *x = type;
|
||||||
if (are_types_identical_unique_tuples(type, other)) {
|
Type *y = entry.key;
|
||||||
OdinDocTypeIndex index = entry.value;
|
|
||||||
map_set(&w->type_cache, type, index);
|
if (x == y) {
|
||||||
return index;
|
goto do_set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!x | !y) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (x->kind == Type_Named) {
|
||||||
|
Entity *e = x->Named.type_name;
|
||||||
|
if (e->TypeName.is_type_alias) {
|
||||||
|
x = x->Named.base;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (y->kind == Type_Named) {
|
||||||
|
Entity *e = y->Named.type_name;
|
||||||
|
if (e->TypeName.is_type_alias) {
|
||||||
|
y = y->Named.base;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (x->kind != y->kind) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!are_types_identical_internal(x, y, true)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
do_set:
|
||||||
|
OdinDocTypeIndex index = entry.value;
|
||||||
|
map_set(&w->type_cache, type, index);
|
||||||
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user