Make doc writer use the old "Ordered Insertion" based PtrMap

This commit is contained in:
gingerBill
2024-05-11 16:24:37 +01:00
parent 8e263de4aa
commit ad0053b798
2 changed files with 449 additions and 23 deletions

View File

@@ -26,11 +26,11 @@ struct OdinDocWriter {
StringMap<OdinDocString> string_cache;
PtrMap<AstFile *, OdinDocFileIndex> file_cache;
PtrMap<AstPackage *, OdinDocPkgIndex> pkg_cache;
PtrMap<Entity *, OdinDocEntityIndex> entity_cache;
PtrMap<Type *, OdinDocTypeIndex> type_cache;
PtrMap<Type *, Type *> stable_type_cache;
OrderedInsertPtrMap<AstFile *, OdinDocFileIndex> file_cache;
OrderedInsertPtrMap<AstPackage *, OdinDocPkgIndex> pkg_cache;
OrderedInsertPtrMap<Entity *, OdinDocEntityIndex> entity_cache;
OrderedInsertPtrMap<Type *, OdinDocTypeIndex> type_cache;
OrderedInsertPtrMap<Type *, Type *> stable_type_cache;
OdinDocWriterItemTracker<OdinDocFile> files;
OdinDocWriterItemTracker<OdinDocPkg> pkgs;
@@ -57,11 +57,11 @@ gb_internal void odin_doc_writer_prepare(OdinDocWriter *w) {
string_map_init(&w->string_cache);
map_init(&w->file_cache);
map_init(&w->pkg_cache);
map_init(&w->entity_cache);
map_init(&w->type_cache);
map_init(&w->stable_type_cache);
map_init(&w->file_cache, 1<<10);
map_init(&w->pkg_cache, 1<<10);
map_init(&w->entity_cache, 1<<18);
map_init(&w->type_cache, 1<<18);
map_init(&w->stable_type_cache, 1<<18);
odin_doc_writer_item_tracker_init(&w->files, 1);
odin_doc_writer_item_tracker_init(&w->pkgs, 1);
@@ -485,6 +485,13 @@ gb_internal OdinDocTypeIndex odin_doc_type(OdinDocWriter *w, Type *type) {
return 0;
}
if (type->kind == Type_Named) {
Entity *e = type->Named.type_name;
if (e->TypeName.is_type_alias) {
type = type->Named.base;
}
}
// Type **mapped_type = map_get(&w->stable_type_cache, type); // may map to itself
// if (mapped_type && *mapped_type) {
// type = *mapped_type;
@@ -506,13 +513,6 @@ gb_internal OdinDocTypeIndex odin_doc_type(OdinDocWriter *w, Type *type) {
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) {