lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]



-- Joins an array into text separated by separator
function join(arr, sep)
    if #arr == 0 then return "" end
    local res = arr[1]
    for i = 2,#arr do
        res = res .. sep .. arr[i]
    end
    return res
end

    Why do you use this instead of table.concat? Since strings are
immutable, this code can use a lot of memory, as explained in PiL.

Sloppy reading of the documentation. I somehow missed table.concat. I'll make a new release tomorrow that fixes this and any other problems that are found until then.

Overall, markdown.lua is pretty slow as parsers go. It makes a lot of passes over the source file, substituting different things in each pass. (markdown.pl works the same way.)

// Niklas