From f22390ac3f273defcf6988b9ab3c805ced85323c Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Tue, 31 Oct 2017 11:41:57 -0400 Subject: [PATCH] short-circuit some iterations in `jl_recache_type` to speed up loading of large precompiled packages. (#24407) extracted from #24399 (cherry picked from commit b8d42d43d3d5bc3c1cf999dd8c24481c8b1594f4) --- src/dump.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/dump.c b/src/dump.c index 0b9d3e228da5e7..c49bc2168e79f1 100644 --- a/src/dump.c +++ b/src/dump.c @@ -3035,6 +3035,8 @@ static jl_datatype_t *jl_recache_type(jl_datatype_t *dt, size_t start, jl_value_ t = dt; } assert(t->uid != 0); + if (t == dt && v == NULL) + return t; // delete / replace any other usages of this type in the backref list // with the newly constructed object size_t i = start; @@ -3087,8 +3089,7 @@ static void jl_recache_types(void) if (jl_is_datatype(o)) { dt = (jl_datatype_t*)o; v = dt->instance; - assert(dt->uid == -1); - t = jl_recache_type(dt, i + 2, NULL); + t = dt->uid == -1 ? jl_recache_type(dt, i + 2, NULL) : dt; } else { dt = (jl_datatype_t*)jl_typeof(o);