summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulian <MyFakeAcc.4@googlemail.com>2016-09-11 03:34:44 +0200
committerwm4 <wm4@nowhere>2017-10-09 20:40:31 +0200
commitb58b812384c2a1f37a55a0cb8ae55d6ed2c801e3 (patch)
tree7c59230a2ee5717be4b597e84e242565dac98399
parentfa0b1f071aff39e6c430bbd97308148e60504a85 (diff)
downloadmpv-b58b812384c2a1f37a55a0cb8ae55d6ed2c801e3.tar.bz2
mpv-b58b812384c2a1f37a55a0cb8ae55d6ed2c801e3.tar.xz
stats: access less variables outside function's state
-rw-r--r--player/lua/stats.lua22
1 files changed, 10 insertions, 12 deletions
diff --git a/player/lua/stats.lua b/player/lua/stats.lua
index db6d41fa90..74bb1db468 100644
--- a/player/lua/stats.lua
+++ b/player/lua/stats.lua
@@ -139,29 +139,27 @@ local function has_ansi()
end
-local function generate_graph(values, v_max, scale)
- -- check if at least one value was recorded yet
- if ppos < 1 then
+local function generate_graph(values, i, len, v_max, scale)
+ -- check if at least one value was recorded yet (we assume lua-style 1-indexing)
+ if i < 1 then
return ""
end
local x_tics = 1
- local x_max = (plen - 1) * x_tics
+ local x_max = (len - 1) * x_tics
local y_offset = o.border_size
local y_max = o.font_size * 0.66
local x = 0
-
- local i = ppos
local s = {format("m 0 0 n %f %f l ", x, y_max - (y_max * values[i] / v_max * scale))}
- i = ((i - 2) % plen) + 1
+ i = ((i - 2) % len) + 1
- for p = 1, plen - 1 do
+ for p = 1, len - 1 do
if values[i] then
x = x - x_tics
s[#s+1] = format("%f %f ", x, y_max - (y_max * values[i] / v_max * scale))
end
- i = ((i - 2) % plen) + 1
+ i = ((i - 2) % len) + 1
end
s[#s+1] = format("%f %f %f %f", x, y_max, 0, y_max)
@@ -217,9 +215,9 @@ local function append_perfdata(s)
max[2], max[3] = max[1], max[1]
end
- rsuffix = generate_graph(plast[1], max[1], 0.8)
- psuffix = generate_graph(plast[2], max[2], 0.8)
- usuffix = generate_graph(plast[3], max[3], 0.8)
+ rsuffix = generate_graph(plast[1], ppos, plen, max[1], 0.8)
+ psuffix = generate_graph(plast[2], ppos, plen, max[2], 0.8)
+ usuffix = generate_graph(plast[3], ppos, plen, max[3], 0.8)
s[#s+1] = format("%s%s%s%s{\\fs%s}%s%s%s{\\fs%s}", o.nl, o.indent,
b("Frame Timings:"), o.prefix_sep, o.font_size * 0.66,