From cc17dcae6df9247b32cbeeee59af677838d1b3f5 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sun, 10 Apr 2016 11:01:50 +0200 Subject: [db] do not rely on __gc for font object lifetimes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The penalty for having font object closed automatically is huge: It takes around nine seconds more to rebuild the font database: 58 s with __gc, 49 s by closing manually. Even if it’s not the default, we reintroduce the code for closing fonts manually to avoid that situation. --- src/luaotfload-database.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/luaotfload-database.lua b/src/luaotfload-database.lua index 7c5e69b..7d0c86b 100644 --- a/src/luaotfload-database.lua +++ b/src/luaotfload-database.lua @@ -60,6 +60,7 @@ fonts.handlers = fontshandlers local read_font_file = otfhandler.readers.getinfo local read_font_info = read_font_file +local close_font_file = function () end local gzipload = gzip.load local gzipsave = gzip.save @@ -1457,6 +1458,8 @@ ot_fullinfo = function (filename, return nil end + close_font_file (metadata) --> FF only + local rawinfo = get_raw_info (metadata, basename) local english_names = get_english_names (rawinfo) local namedata = organize_namedata (rawinfo, @@ -3425,9 +3428,11 @@ local use_fontforge = function (val) local fontloader = fontloader read_font_info = fontloader.info read_font_file = fontloader.open + close_font_file = fontloader.close else read_font_file = otfhandler.readers.getinfo read_font_info = read_font_file + close_font_file = function () end end end -- cgit v1.2.3