aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2023-09-09 02:17:11 +0300
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2023-09-09 02:17:11 +0300
commite409cea4435608ad6d53ebffe6a06f34142b1fa7 (patch)
treede8723cd05ca929b9ca2a30f6e316b994dd6d4d1
parent5ff0b15bbed7fe25a50c49dc52f561738b45b09e (diff)
downloadapplause2-e409cea4435608ad6d53ebffe6a06f34142b1fa7.tar.gz
cache the value in simple value streams
* analyzing the bytecode via tostream(...):jdump() has shown that this might be more efficient
-rw-r--r--applause.lua4
1 files changed, 3 insertions, 1 deletions
diff --git a/applause.lua b/applause.lua
index 20bce20..96beada 100644
--- a/applause.lua
+++ b/applause.lua
@@ -188,8 +188,10 @@ Stream.channels = 1
-- A stream, produces an infinite number of the same value by default
-- (eternal quietness by default)
function Stream:gtick()
+ local value = self.value
+
return function()
- return self.value
+ return value
end
end