[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: [luarocks] lub.join is slow and probably unnecessary
- From: Dirk Laurie <dirk.laurie@...>
- Date: Fri, 13 Jul 2018 06:34:20 +0200
I use the 'xml' luarock which depends on the 'lub' rock.
I like it very much, but found that 'xml.dump' becomes very
slow when the XML string is very long.
I traced the reason to its use of the function 'lub.join'. This
function concatenates a list by repeatedly concatenating
the next element to the partial result, an algorithm that takes
O(n²) time, where n is the length of the final result.
Applications (such as 'xml') that do not need __concat
metamethods do not need that algorithm.
require"lub".join = table.concat
solves all the speed problems.
-- Dirk