summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMateusz Czaplinski <mateusz@czaplinski.pl>2011-05-30 21:16:09 +0200
committerMateusz Czaplinski <mateusz@czaplinski.pl>2011-05-30 21:16:09 +0200
commitc374d754005e508a1631b32aa5014ab5b9d49b73 (patch)
tree073acf80d014e2373d9d319b40471e4f3675c96b
parent6c11ccf4a6c7e7a2a6eb79b2453f6d2e6a7a2dec (diff)
downloadluacov-c374d754005e508a1631b32aa5014ab5b9d49b73.tar.gz
Reformatted a code block to reduce indentation level by early return.
-rw-r--r--src/luacov.lua31
1 files changed, 14 insertions, 17 deletions
diff --git a/src/luacov.lua b/src/luacov.lua
index 63a178e..c7ec710 100644
--- a/src/luacov.lua
+++ b/src/luacov.lua
@@ -19,25 +19,22 @@ local function on_line(_, line_nr)
end
end
+ -- get name of processed file; ignore Lua code loaded from raw strings
local name = debug.getinfo(2, "S").source
- if name:match("^@") then
- name = name:sub(2)
- local file = data[name]
- if not file then
- file = {}
- file.max = 0
- data[name] = file
- end
- if line_nr > file.max then
- file.max = line_nr
- end
- local current = file[line_nr]
- if not current then
- file[line_nr] = 1
- else
- file[line_nr] = current + 1
- end
+ if not name:match("^@") then
+ return
+ end
+ name = name:sub(2)
+
+ local file = data[name]
+ if not file then
+ file = {max=0}
+ data[name] = file
+ end
+ if line_nr > file.max then
+ file.max = line_nr
end
+ file[line_nr] = (file[line_nr] or 0) + 1
end
local function on_exit()