Skip to content

Commit 3deb202

Browse files
authored
fix: optimize judgment statements (#157)
1 parent 57338a4 commit 3deb202

File tree

1 file changed

+11
-54
lines changed

1 file changed

+11
-54
lines changed

lib/resty/etcd/v3.lua

Lines changed: 11 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -432,60 +432,17 @@ local function get(self, key, attr)
432432
range_end = encode_base64(attr.range_end)
433433
end
434434

435-
local limit
436-
if attr.limit then
437-
limit = attr.limit and attr.limit or 0
438-
end
439-
440-
local revision
441-
if attr.revision then
442-
revision = attr.revision and attr.revision or 0
443-
end
444-
445-
local sort_order
446-
if attr.sort_order then
447-
sort_order = attr.sort_order and attr.sort_order or 0
448-
end
449-
450-
local sort_target
451-
if attr.sort_target then
452-
sort_target = attr.sort_target and attr.sort_target or 0
453-
end
454-
455-
local serializable
456-
if attr.serializable then
457-
serializable = attr.serializable and true or false
458-
end
459-
460-
local keys_only
461-
if attr.keys_only then
462-
keys_only = attr.keys_only and true or false
463-
end
464-
465-
local count_only
466-
if attr.count_only then
467-
count_only = attr.count_only and true or false
468-
end
469-
470-
local min_mod_revision
471-
if attr.min_mod_revision then
472-
min_mod_revision = attr.min_mod_revision or 0
473-
end
474-
475-
local max_mod_revision
476-
if attr.max_mod_revision then
477-
max_mod_revision = attr.max_mod_revision or 0
478-
end
479-
480-
local min_create_revision
481-
if attr.min_create_revision then
482-
min_create_revision = attr.min_create_revision or 0
483-
end
484-
485-
local max_create_revision
486-
if attr.max_create_revision then
487-
max_create_revision = attr.max_create_revision or 0
488-
end
435+
local limit = attr.limit or 0
436+
local revision = attr.revision or 0
437+
local sort_order = attr.sort_order or 0
438+
local sort_target = attr.sort_target or 0
439+
local serializable = attr.serializable or false
440+
local keys_only = attr.keys_only or false
441+
local count_only = attr.count_only or false
442+
local min_mod_revision = attr.min_mod_revision or 0
443+
local max_mod_revision = attr.max_mod_revision or 0
444+
local min_create_revision = attr.min_create_revision or 0
445+
local max_create_revision = attr.max_create_revision or 0
489446

490447
key = encode_base64(key)
491448

0 commit comments

Comments
 (0)