History

lua: remove a ton of unneeded parentheses

For whatever reason, some of the lua code (particularly the osc and ytdl_hook) is full of a bunch of stuff like if (foo), if not (foo == nil), etc. The parenthesis aren't needed in lua and actually just look weird since nobody actually writes lua like this. You can see most of the other conditionals are written normally. So cleanup the style to match when the parenthesis clearly aren't doing anything. Not directly related, but also add some spaces on a few math operations while we're at it.

Dudemanguy committed 3 years ago

Commit fcc67cc1 parent 56fada15 files · +146 −147Browse files

Showing the changes to player/lua/defaults.lua (1 of 5 files). Show all

Unified · Split

player/lua/defaults.lua+4−4
@@ -175,7 +175,7 @@ function mp.flush_keybindings() · 174 unmodified lines
175end175end
176 176
177local function add_binding(attrs, key, name, fn, rp)177local function add_binding(attrs, key, name, fn, rp)
178 if (type(name) ~= "string") and (name ~= nil) then178 if type(name) ~= "string" and name ~= nil then
179 rp = fn179 rp = fn
180 fn = name180 fn = name
181 name = nil181 name = nil
@@ -226,7 +226,7 @@ local function add_binding(attrs, key, name, fn, rp) · 44 unmodified lines
226 end226 end
227 if is_mouse and (event == "u" or event == "p") then227 if is_mouse and (event == "u" or event == "p") then
228 fn()228 fn()
229 elseif (not is_mouse) and (event == "d" or event == "r" or event == "p") then229 elseif not is_mouse and (event == "d" or event == "r" or event == "p") then
230 fn()230 fn()
231 end231 end
232 end232 end
@@ -316,7 +316,7 @@ end · 83 unmodified lines
316local function get_next_timer()316local function get_next_timer()
317 local best = nil317 local best = nil
318 for t, _ in pairs(timers) do318 for t, _ in pairs(timers) do
319 if (best == nil) or (t.next_deadline < best.next_deadline) then319 if best == nil or t.next_deadline < best.next_deadline then
320 best = t320 best = t
321 end321 end
322 end322 end
@@ -598,7 +598,7 @@ mp.register_event("hook", function(ev) · 275 unmodified lines
598 if fn then598 if fn then
599 fn(hookobj)599 fn(hookobj)
600 end600 end
601 if (not hookobj._defer) and hookobj._id ~= nil then601 if not hookobj._defer and hookobj._id ~= nil then
602 hookobj:cont()602 hookobj:cont()
603 end603 end
604end)604end)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t