[latex3-commits] [git/LaTeX3-latex3-luaotfload] lessglobals-dev: Less globals (5845f03)

Marcel Fabian Krüger tex at 2krueger.de
Mon Sep 2 14:38:34 CEST 2019


Repository : https://github.com/latex3/luaotfload
On branch  : lessglobals-dev
Link       : https://github.com/latex3/luaotfload/commit/5845f03a21c3e7a8f63db32e6cf12a78a7bca2c7

>---------------------------------------------------------------

commit 5845f03a21c3e7a8f63db32e6cf12a78a7bca2c7
Author: Marcel Fabian Krüger <tex at 2krueger.de>
Date:   Sat Aug 31 16:25:39 2019 +0200

    Less globals


>---------------------------------------------------------------

5845f03a21c3e7a8f63db32e6cf12a78a7bca2c7
 src/luaotfload-configuration.lua                            |  2 +-
 src/luaotfload-database.lua                                 |  5 ++---
 src/luaotfload-features.lua                                 | 12 +++++-------
 src/luaotfload-log.lua                                      |  6 +++---
 texmf/tex/latex-dev/luaotfload/luaotfload-configuration.lua |  2 +-
 texmf/tex/latex-dev/luaotfload/luaotfload-database.lua      |  5 ++---
 texmf/tex/latex-dev/luaotfload/luaotfload-features.lua      | 12 +++++-------
 texmf/tex/latex-dev/luaotfload/luaotfload-log.lua           |  6 +++---
 8 files changed, 22 insertions(+), 28 deletions(-)

diff --git a/src/luaotfload-configuration.lua b/src/luaotfload-configuration.lua
index 24b40ad..33eb797 100644
--- a/src/luaotfload-configuration.lua
+++ b/src/luaotfload-configuration.lua
@@ -382,7 +382,7 @@ local set_default_features = function ()
                              global   = { },
                              defaults = { },
                            }
-  current_features       = luaotfload.features
+  local current_features = luaotfload.features
   for var, val in next, default_features do
     if var == "global" then
       current_features.global = val
diff --git a/src/luaotfload-database.lua b/src/luaotfload-database.lua
index 4392f85..009d2d9 100644
--- a/src/luaotfload-database.lua
+++ b/src/luaotfload-database.lua
@@ -2125,9 +2125,8 @@ do
             return
         end
 
-        if splitcomma == nil then
-            splitcomma = luaotfload.parsers and luaotfload.parsers.splitcomma
-        end
+        local splitcomma = luaotfload.parsers and luaotfload.parsers.splitcomma
+
         if stringsub (formats, 1, 1) == "+" then -- add
             formats = lpegmatch (splitcomma, stringsub (formats, 2))
             if formats then
diff --git a/src/luaotfload-features.lua b/src/luaotfload-features.lua
index 8e6dd70..b23905c 100644
--- a/src/luaotfload-features.lua
+++ b/src/luaotfload-features.lua
@@ -572,8 +572,8 @@ local autofeatures = {
 
 local add_auto_features = function ()
     local nfeats = #autofeatures
-    logreport ("both", 5, "features",
-               "auto-installing %d feature definitions", nfeats)
+    report ("both", 5, "features",
+            "auto-installing %d feature definitions", nfeats)
     for i = 1, nfeats do
         local name, spec, desc = unpack (autofeatures [i])
         spec.description = desc
@@ -582,12 +582,10 @@ local add_auto_features = function ()
 end
 
 return function ()
-    logreport = luaotfload.log.report
-
     if not fonts and fonts.handlers then
-        logreport ("log", 0, "features",
-                   "OTF mechanisms missing -- did you forget to \z
-                   load a font loader?")
+        report ("log", 0, "features",
+                "OTF mechanisms missing -- did you forget to \z
+                load a font loader?")
         return false
     end
     add_auto_features ()
diff --git a/src/luaotfload-log.lua b/src/luaotfload-log.lua
index 7a2e41f..36ece82 100644
--- a/src/luaotfload-log.lua
+++ b/src/luaotfload-log.lua
@@ -220,16 +220,16 @@ else
     end
 end
 
-stdout = function (writer, category, ...)
+local stdout = function (writer, category, ...)
     local res = { module_name, "|", category, ":" }
     local nargs = select("#", ...)
     if nargs == 0 then
         --writeln tableconcat(res, " ")
         --return
     elseif nargs == 1 then
-        res[#res+1] = select(1, ...) -- around 30% faster than unpack()
+        res[5] = ... -- around 30% faster than unpack()
     else
-        res[#res+1] = stringformat(...)
+        res[5] = stringformat(...)
     end
     writer (tableconcat(res, " "))
 end
diff --git a/texmf/tex/latex-dev/luaotfload/luaotfload-configuration.lua b/texmf/tex/latex-dev/luaotfload/luaotfload-configuration.lua
index 24b40ad..33eb797 100644
--- a/texmf/tex/latex-dev/luaotfload/luaotfload-configuration.lua
+++ b/texmf/tex/latex-dev/luaotfload/luaotfload-configuration.lua
@@ -382,7 +382,7 @@ local set_default_features = function ()
                              global   = { },
                              defaults = { },
                            }
-  current_features       = luaotfload.features
+  local current_features = luaotfload.features
   for var, val in next, default_features do
     if var == "global" then
       current_features.global = val
diff --git a/texmf/tex/latex-dev/luaotfload/luaotfload-database.lua b/texmf/tex/latex-dev/luaotfload/luaotfload-database.lua
index 4392f85..009d2d9 100644
--- a/texmf/tex/latex-dev/luaotfload/luaotfload-database.lua
+++ b/texmf/tex/latex-dev/luaotfload/luaotfload-database.lua
@@ -2125,9 +2125,8 @@ do
             return
         end
 
-        if splitcomma == nil then
-            splitcomma = luaotfload.parsers and luaotfload.parsers.splitcomma
-        end
+        local splitcomma = luaotfload.parsers and luaotfload.parsers.splitcomma
+
         if stringsub (formats, 1, 1) == "+" then -- add
             formats = lpegmatch (splitcomma, stringsub (formats, 2))
             if formats then
diff --git a/texmf/tex/latex-dev/luaotfload/luaotfload-features.lua b/texmf/tex/latex-dev/luaotfload/luaotfload-features.lua
index 8e6dd70..b23905c 100644
--- a/texmf/tex/latex-dev/luaotfload/luaotfload-features.lua
+++ b/texmf/tex/latex-dev/luaotfload/luaotfload-features.lua
@@ -572,8 +572,8 @@ local autofeatures = {
 
 local add_auto_features = function ()
     local nfeats = #autofeatures
-    logreport ("both", 5, "features",
-               "auto-installing %d feature definitions", nfeats)
+    report ("both", 5, "features",
+            "auto-installing %d feature definitions", nfeats)
     for i = 1, nfeats do
         local name, spec, desc = unpack (autofeatures [i])
         spec.description = desc
@@ -582,12 +582,10 @@ local add_auto_features = function ()
 end
 
 return function ()
-    logreport = luaotfload.log.report
-
     if not fonts and fonts.handlers then
-        logreport ("log", 0, "features",
-                   "OTF mechanisms missing -- did you forget to \z
-                   load a font loader?")
+        report ("log", 0, "features",
+                "OTF mechanisms missing -- did you forget to \z
+                load a font loader?")
         return false
     end
     add_auto_features ()
diff --git a/texmf/tex/latex-dev/luaotfload/luaotfload-log.lua b/texmf/tex/latex-dev/luaotfload/luaotfload-log.lua
index 7a2e41f..36ece82 100644
--- a/texmf/tex/latex-dev/luaotfload/luaotfload-log.lua
+++ b/texmf/tex/latex-dev/luaotfload/luaotfload-log.lua
@@ -220,16 +220,16 @@ else
     end
 end
 
-stdout = function (writer, category, ...)
+local stdout = function (writer, category, ...)
     local res = { module_name, "|", category, ":" }
     local nargs = select("#", ...)
     if nargs == 0 then
         --writeln tableconcat(res, " ")
         --return
     elseif nargs == 1 then
-        res[#res+1] = select(1, ...) -- around 30% faster than unpack()
+        res[5] = ... -- around 30% faster than unpack()
     else
-        res[#res+1] = stringformat(...)
+        res[5] = stringformat(...)
     end
     writer (tableconcat(res, " "))
 end





More information about the latex3-commits mailing list