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
175175 end
176176
177177 local function add_binding(attrs, key, name, fn, rp)
178− if (type(name) ~= "string") and (name ~= nil) then
178+ if type(name) ~= "string" and name ~= nil then
179179 rp = fn
180180 fn = name
181181 name = nil
@@ -226,7 +226,7 @@ local function add_binding(attrs, key, name, fn, rp) · 44 unmodified lines
226226 end
227227 if is_mouse and (event == "u" or event == "p") then
228228 fn()
229− elseif (not is_mouse) and (event == "d" or event == "r" or event == "p") then
229+ elseif not is_mouse and (event == "d" or event == "r" or event == "p") then
230230 fn()
231231 end
232232 end
@@ -316,7 +316,7 @@ end · 83 unmodified lines
316316 local function get_next_timer()
317317 local best = nil
318318 for t, _ in pairs(timers) do
319− if (best == nil) or (t.next_deadline < best.next_deadline) then
319+ if best == nil or t.next_deadline < best.next_deadline then
320320 best = t
321321 end
322322 end
@@ -598,7 +598,7 @@ mp.register_event("hook", function(ev) · 275 unmodified lines
598598 if fn then
599599 fn(hookobj)
600600 end
601− if (not hookobj._defer) and hookobj._id ~= nil then
601+ if not hookobj._defer and hookobj._id ~= nil then
602602 hookobj:cont()
603603 end
604604 end)

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