From 2f594e712821846256d936c19eefa0f994938b06 Mon Sep 17 00:00:00 2001 From: Manuel Simon Hirsig Date: Mon, 15 Aug 2016 19:01:39 +0200 Subject: [PATCH] refactoring --- components/slash.lua | 2 +- core.lua | 6 +++--- tabs/search/frames.lua | 2 +- tabs/search/results.lua | 2 +- util/core.lua | 9 --------- util/info.lua | 6 +++--- util/money.lua | 2 +- util/persistence.lua | 4 ++-- 8 files changed, 12 insertions(+), 21 deletions(-) diff --git a/components/slash.lua b/components/slash.lua index 70d9ae1..ab48dd5 100644 --- a/components/slash.lua +++ b/components/slash.lua @@ -77,7 +77,7 @@ function SlashCmdList.AUX(command) tinsert(chars, name) end if getn(chars) > 0 then - aux.log('Your characters: "'..aux.util.join(chars, ', ')..'".') + aux.log('Your characters: "'..table.concat(chars, ', ')..'".') else aux.log('You don\'t have any additional characters. To add your characters type "/aux chars add NAME1 NAME2 NAME3...".') end diff --git a/core.lua b/core.lua index d394108..e17ce3a 100644 --- a/core.lua +++ b/core.lua @@ -8,13 +8,13 @@ do local data = {} local mt = { __newindex = function(self, key, value) - data[self].getter({public=self, private=data[self].state})[key] = value + data[self].getter{public=self, private=data[self].state}[key] = value end, __index = function(self, key) - return data[self].getter({public=self, private=data[self].state})[key] + return data[self].getter{public=self, private=data[self].state}[key] end, __call = function(self) - return data[self].getter({public=self, private=data[self].state}) + return data[self].getter{public=self, private=data[self].state} end, } function public.dynamic_table(state, getter) diff --git a/tabs/search/frames.lua b/tabs/search/frames.lua index 9ec6df3..74a2592 100644 --- a/tabs/search/frames.lua +++ b/tabs/search/frames.lua @@ -336,7 +336,7 @@ function private.create_frames() if filters then tinsert(aux_favorite_searches, 1, { filter_string = m.search_box:GetText(), - prettified = aux.util.join(aux.util.map(filters, function(filter) return filter.prettified end), ';'), + prettified = table.concat(aux.util.map(filters, function(filter) return filter.prettified end), ';'), }) end m.update_search_listings() diff --git a/tabs/search/results.lua b/tabs/search/results.lua index 9a14fd0..10d76a5 100644 --- a/tabs/search/results.lua +++ b/tabs/search/results.lua @@ -335,7 +335,7 @@ function public.execute(resume, real_time) else m.new_search(filter_string) end - m.new_recent_search(filter_string, aux.util.join(aux.util.map(queries, function(filter) return filter.prettified end), ';')) + m.new_recent_search(filter_string, table.concat(aux.util.map(queries, function(filter) return filter.prettified end), ';')) else m.current_search().records = {} m.current_search().table:SetDatabase(m.current_search().records) diff --git a/util/core.lua b/util/core.lua index 31c41f6..5a98c79 100644 --- a/util/core.lua +++ b/util/core.lua @@ -158,15 +158,6 @@ function public.trim(str) return gsub(str, '^%s*(.-)%s*$', '%1') end -function public.join(parts, separator) - local str = parts[1] or '' - for i=2,getn(parts) do - if not parts[i] then break end - str = str..separator..parts[i] - end - return str -end - function public.split(str, separator) local parts = {} while true do diff --git a/util/info.lua b/util/info.lua index 245b733..c802078 100644 --- a/util/info.lua +++ b/util/info.lua @@ -124,8 +124,8 @@ function public.auction(index, query_type) hyperlink = hyperlink, itemstring = item_info.itemstring, item_key = item_id..':'..suffix_id, - search_signature = aux.util.join({item_id, suffix_id, enchant_id, start_price, buyout_price, bid_price, aux_quantity, duration, query_type == 'owner' and high_bidder or (high_bidder and 1 or 0), aux_ignore_owner and (aux.is_player(owner) and 0 or 1) or (owner or '?')}, ':'), - sniping_signature = aux.util.join({item_id, suffix_id, enchant_id, start_price, buyout_price, aux_quantity, aux_ignore_owner and (aux.is_player(owner, true) and 0 or 1) or (owner or '?')}, ':'), + search_signature = table.concat({item_id, suffix_id, enchant_id, start_price, buyout_price, bid_price, aux_quantity, duration, query_type == 'owner' and high_bidder or (high_bidder and 1 or 0), aux_ignore_owner and (aux.is_player(owner) and 0 or 1) or (owner or '?')}, ':'), + sniping_signature = table.concat({item_id, suffix_id, enchant_id, start_price, buyout_price, aux_quantity, aux_ignore_owner and (aux.is_player(owner, true) and 0 or 1) or (owner or '?')}, ':'), name = name, texture = texture, @@ -169,7 +169,7 @@ function public.bid_update(auction_record) auction_record.unit_blizzard_bid = auction_record.blizzard_bid / auction_record.aux_quantity auction_record.unit_bid_price = auction_record.bid_price / auction_record.aux_quantity auction_record.high_bidder = 1 - auction_record.search_signature = aux.util.join({auction_record.item_id, auction_record.suffix_id, auction_record.enchant_id, auction_record.start_price, auction_record.buyout_price, auction_record.bid_price, auction_record.aux_quantity, auction_record.duration, 1, aux_ignore_owner and (aux.is_player(auction_record.owner) and 0 or 1) or (auction_record.owner or '?')}, ':') + auction_record.search_signature = table.concat({auction_record.item_id, auction_record.suffix_id, auction_record.enchant_id, auction_record.start_price, auction_record.buyout_price, auction_record.bid_price, auction_record.aux_quantity, auction_record.duration, 1, aux_ignore_owner and (aux.is_player(auction_record.owner) and 0 or 1) or (auction_record.owner or '?')}, ':') end function public.set_tooltip(itemstring, owner, anchor) diff --git a/util/money.lua b/util/money.lua index 43d230e..25264b1 100644 --- a/util/money.lua +++ b/util/money.lua @@ -92,7 +92,7 @@ function public.to_string(money, pad, trim, decimal_points, color, no_color) if copper > 0 or gold == 0 and silver == 0 then tinsert(parts, m.format_number(copper, pad, decimal_points, color)..copper_text) end - text = aux.util.join(parts, ' ') + text = table.concat(parts, ' ') else if gold > 0 then text = m.format_number(gold, false, nil, color)..gold_text..' '..m.format_number(silver, pad, nil, color)..silver_text..' '..m.format_number(copper, pad, decimal_points, color)..copper_text diff --git a/util/persistence.lua b/util/persistence.lua index f8e119d..9d2fa31 100644 --- a/util/persistence.lua +++ b/util/persistence.lua @@ -72,7 +72,7 @@ function public.write_list(schema, list) local parts = aux.util.map(list, function(element) return m.write(element_type, element) end) - return aux.util.join(parts, separator) + return table.concat(parts, separator) end function public.read_record(schema, str) @@ -93,7 +93,7 @@ function public.write_record(schema, record) local key, type = next(schema[i]) tinsert(parts, m.write(type, record[key])) end - return aux.util.join(parts, separator) + return table.concat(parts, separator) end function public.serialize(data, separator, compactor)