From d4b089d508a4bced70a3c59dc0af16f6a553fcb0 Mon Sep 17 00:00:00 2001 From: Manuel Simon Hirsig Date: Fri, 2 Jun 2017 19:38:41 +0200 Subject: [PATCH] tbc loop change part 2 --- tabs/search/filter.lua | 5 ++--- tabs/search/frame.lua | 4 ++-- tabs/search/results.lua | 6 +++--- tabs/search/saved.lua | 2 +- util/completion.lua | 6 +++--- util/filter.lua | 9 ++++----- 6 files changed, 15 insertions(+), 17 deletions(-) diff --git a/tabs/search/filter.lua b/tabs/search/filter.lua index 445b462..2eb5ce9 100644 --- a/tabs/search/filter.lua +++ b/tabs/search/filter.lua @@ -152,8 +152,7 @@ end function set_form(filter) clear_form() - for i = 1, getn(filter.components) do - local component = filter.components[i] + for _, component in ipairs(filter.components) do if component[1] == 'blizzard' then blizzard_query[component[2]] = component[4] else @@ -199,7 +198,7 @@ function formatted_post_filter(components) local stack = temp-T local str = '' - for i = 1, getn(components) do + for i, component in ipairs(components) do local component = components[i] if no_line_break then str = str .. ' ' diff --git a/tabs/search/frame.lua b/tabs/search/frame.lua index 06650b7..c39bbbe 100644 --- a/tabs/search/frame.lua +++ b/tabs/search/frame.lua @@ -541,8 +541,8 @@ favorite_searches_listing:SetColInfo{{name='Auto Buy', width=.07, align='CENTER' recent_searches_listing = listing.new(frame.saved.recent) recent_searches_listing:SetColInfo{{name='Recent Searches', width=1}} -for listing in temp-S(favorite_searches_listing, recent_searches_listing) do - for k, v in handlers do +for listing in pairs(temp-S(favorite_searches_listing, recent_searches_listing)) do + for k, v in pairs(handlers) do listing:SetHandler(k, v) end end \ No newline at end of file diff --git a/tabs/search/results.lua b/tabs/search/results.lua index 056d40a..1cad0a7 100644 --- a/tabs/search/results.lua +++ b/tabs/search/results.lua @@ -175,10 +175,10 @@ function start_real_time_scan(query, search, continuation) end, on_complete = function() local map = temp-T - for _, record in search.records do + for _, record in pairs(search.records) do map[record.sniping_signature] = record end - for _, record in new_records do + for _, record in pairs(new_records) do map[record.sniping_signature] = record end release(new_records) @@ -352,7 +352,7 @@ function M.execute(resume, real_time) if real_time then start_real_time_scan(queries[1], nil, continuation) else - for _, query in queries do + for _, query in pairs(queries) do query.blizzard_query.first_page = current_search.first_page query.blizzard_query.last_page = current_search.last_page end diff --git a/tabs/search/saved.lua b/tabs/search/saved.lua index a5b3898..4f79a0b 100644 --- a/tabs/search/saved.lua +++ b/tabs/search/saved.lua @@ -84,7 +84,7 @@ handlers = { function get_auto_buy_validator() local validators = T - for _, search in favorite_searches do + for _, search in pairs(favorite_searches) do if search.auto_buy then local queries, error = filter_util.queries(search.filter_string) if queries then diff --git a/util/completion.lua b/util/completion.lua index 58dd100..cac6813 100644 --- a/util/completion.lua +++ b/util/completion.lua @@ -18,9 +18,9 @@ function M:complete_filter() local start_index, _, current_modifier = strfind(filter_string, '([^/;]*)$') current_modifier = current_modifier or '' - for i = 1, getn(suggestions) do - if strsub(strupper(suggestions[i]), 1, strlen(current_modifier)) == strupper(current_modifier) then - this:SetText(strlower(strsub(filter_string, 1, start_index - 1) .. suggestions[i])) + for _, suggestion in ipairs(suggestions) do + if strsub(strupper(suggestion), 1, strlen(current_modifier)) == strupper(current_modifier) then + this:SetText(strlower(strsub(filter_string, 1, start_index - 1) .. suggestion)) this:HighlightText(strlen(filter_string), -1) return end diff --git a/util/filter.lua b/util/filter.lua index 0665466..f71b946 100644 --- a/util/filter.lua +++ b/util/filter.lua @@ -185,7 +185,7 @@ M.filters = { function operator(str) local operator = str == 'not' and A('operator', 'not', 1) - for name in temp-S('and', 'or') do + for name in pairs(temp-S('and', 'or')) do local arity = select(3, strfind(str, '^' .. name .. '(%d*)$')) if arity then arity = tonumber(arity) @@ -214,12 +214,12 @@ do end end end - for _, parser in temp-A( + for _, parser in pairs(temp-A( temp-A('class', info.item_class_index), temp-A('subclass', vararg-function(arg) return info.item_subclass_index(index(self.class, 2) or 0, unpack(arg)) end), temp-A('slot', vararg-function(arg) return info.item_slot_index(index(self.class, 2) == 2 and 2 or 0, index(self.subclass, 2) or 0, unpack(arg)) end), temp-A('quality', info.item_quality_index) - ) do + )) do if not self[parser[1]] then tinsert(parser, str) local index, label = parser[2](select(3, unpack(parser))) @@ -423,8 +423,7 @@ end function prettified_filter_string(filter) local prettified = query_builder() - for i = 1, getn(filter.components) do - local component = filter.components[i] + for i, component in ipairs(filter.components) do if component[1] == 'blizzard' then if component[2] == 'name' then if filter.blizzard.exact then