aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2015-12-31 15:33:13 +0100
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2015-12-31 15:33:13 +0100
commit856c775316dbcdba36acfab1a3c300b0372d8ecf (patch)
treeaad78e5f902bab4e22b3c54b8362b38208291ec2
parent3b409db5f23a6f4f39467e05f9edf0963721d3ed (diff)
downloadapplause2-856c775316dbcdba36acfab1a3c300b0372d8ecf.tar.gz
support only LuaJIT and use some additional (insignificant) optimizations
-rw-r--r--Makefile7
-rw-r--r--applause.c8
-rw-r--r--applause.lua4
3 files changed, 10 insertions, 9 deletions
diff --git a/Makefile b/Makefile
index ceb7ff8..999fac3 100644
--- a/Makefile
+++ b/Makefile
@@ -2,15 +2,8 @@ CC = gcc
CFLAGS = -std=c99 -Wall -O2
-LUAJIT = yes
-
-ifeq ($(LUAJIT),yes)
LUA_CFLAGS = $(shell pkg-config --cflags luajit)
LUA_LDFLAGS = $(shell pkg-config --libs luajit)
-else
-LUA_CFLAGS = $(shell pkg-config --cflags lua5.1)
-LUA_LDFLAGS = $(shell pkg-config --libs lua5.1)
-endif
READLINE_CFLAGS =
READLINE_LDFLAGS = -lreadline -lhistory
diff --git a/applause.c b/applause.c
index a1af0f3..1097447 100644
--- a/applause.c
+++ b/applause.c
@@ -16,6 +16,7 @@
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>
+#include <luajit.h>
#include <readline/readline.h>
#include <readline/history.h>
@@ -494,6 +495,13 @@ l_Stream_play(lua_State *L)
luaL_checktype(L, -1, LUA_TFUNCTION);
/*
+ * Make sure JIT compilation is turned on for the generator function
+ * and all subfunctions.
+ * This should not be necessary theoretically.
+ */
+ luaJIT_setmode(L, -1, LUAJIT_MODE_ALLFUNC | LUAJIT_MODE_ON);
+
+ /*
* Perform garbage collection cycle and turn it off
* temporarily. This improves the realtime properties
* of the sample generation loop below.
diff --git a/applause.lua b/applause.lua
index c701bc3..644c23d 100644
--- a/applause.lua
+++ b/applause.lua
@@ -2,7 +2,7 @@ local sndfile = require "sndfile"
local ffi = require "ffi"
local bit = require "bit"
--- Make table.new() available
+-- Make table.new() available (a LuaJIT extension)
require "table.new"
--
@@ -336,7 +336,7 @@ function Stream:totable()
end
local tick = self:tick()
- local vector = {}
+ local vector = table.new(self:len(), 0)
while true do
local value = tick()