diff --git a/src/font.c b/src/font.c index a59ebe216b..1bb1eb29a5 100644 --- a/src/font.c +++ b/src/font.c @@ -2797,34 +2797,24 @@ font_list_entities (struct frame *f, Lisp_Object spec) val = XCDR (val); else { - Lisp_Object copy; - val = (driver_list->driver->list) (f, scratch_font_spec); - /* We put zero_vector in the font-cache to indicate that - no fonts matching SPEC were found on the system. - Failure to have this indication in the font cache can - cause severe performance degradation in some rare - cases, see bug#21028. */ - if (NILP (val)) - val = zero_vector; - else - val = Fvconcat (1, &val); - copy = copy_font_spec (scratch_font_spec); - ASET (copy, FONT_TYPE_INDEX, driver_list->driver->type); - XSETCDR (cache, Fcons (Fcons (copy, val), XCDR (cache))); + if (!NILP (val)) + { + Lisp_Object copy = copy_font_spec (scratch_font_spec); + + val = Fvconcat (1, &val); + ASET (copy, FONT_TYPE_INDEX, driver_list->driver->type); + XSETCDR (cache, Fcons (Fcons (copy, val), XCDR (cache))); + } } - if (ASIZE (val) > 0 + + if (VECTORP (val) && ASIZE (val) > 0 && (need_filtering || ! NILP (Vface_ignored_fonts))) val = font_delete_unmatched (val, need_filtering ? spec : Qnil, size); - if (ASIZE (val) > 0) - { - list = Fcons (val, list); - /* Querying further backends can be very slow, so we only do - it if the user has explicitly requested it (Bug#43177). */ - if (query_all_font_backends == false) - break; - } + + if (VECTORP (val) && ASIZE (val) > 0) + list = Fcons (val, list); } list = Fnreverse (list);