aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Lua/Util.hs
diff options
context:
space:
mode:
authorAlbert Krewinkel <albert@zeitkraut.de>2018-01-23 21:29:58 +0100
committerAlbert Krewinkel <albert@zeitkraut.de>2018-01-23 21:29:58 +0100
commit517f65a7cc3e94b9c4ad574369a32c48e0a95be6 (patch)
tree5854e181ab57be4ce9c9d1972fddd65049ef8f26 /src/Text/Pandoc/Lua/Util.hs
parent2e0bb773345f489798666ac3c2d96d3873fa82a3 (diff)
downloadpandoc-517f65a7cc3e94b9c4ad574369a32c48e0a95be6.tar.gz
Lua filters: store constructors in registry
Lua functions used to construct AST element values are stored in the Lua registry for quicker access. Getting a value from the registry is much faster than getting a global value (partly to idiosyncrasies of hslua); this change results in a considerable performance boost.
Diffstat (limited to 'src/Text/Pandoc/Lua/Util.hs')
-rw-r--r--src/Text/Pandoc/Lua/Util.hs5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Lua/Util.hs b/src/Text/Pandoc/Lua/Util.hs
index f82ec4753..b7149af39 100644
--- a/src/Text/Pandoc/Lua/Util.hs
+++ b/src/Text/Pandoc/Lua/Util.hs
@@ -50,7 +50,7 @@ import Control.Monad (when)
import Control.Monad.Catch (finally)
import Data.ByteString.Char8 (unpack)
import Foreign.Lua (FromLuaStack (..), NumResults, Lua, NumArgs, StackIndex,
- ToLuaStack (..), ToHaskellFunction, getglobal')
+ ToLuaStack (..), ToHaskellFunction)
import Foreign.Lua.Api (Status, call, pop, rawget, rawgeti, rawset, rawseti)
import Text.Pandoc.Class (readDataFile, runIOorExplode, setUserDataDir)
@@ -131,7 +131,8 @@ class PushViaCall a where
instance PushViaCall (Lua ()) where
pushViaCall' fn pushArgs num = do
- getglobal' fn
+ Lua.push fn
+ Lua.rawget (Lua.registryindex)
pushArgs
call num 1