Moved the function index() from lume.slice()'s body to local var
absindex, this improves the performance of lume.slice() on luajit
significantly and improves it to a lesser extent on non-jit lua.
Set most of the global funcs / variables which are used to local
variables. This offers better performance in lua 5.1 and 5.2, and seems
to make no difference in luaJIT.
A negative value for the `i` argument of lume.slice() is now handled
properly (used as an index from the end of the string) to mimicing the
behaviour of lua's string.sub()
This makes the series of python-like functions (map, all, any, reduce,
set, filter) consecutive in the source and readme, which seems like a
more logical order.
Changed the returned values from pcall() in lume.hotswap() to be handled
correctly -- the second return value being the wrapped-function's first
return value. This bug would effect hotswapped modules which used the
modern approach of returning a table rather than creating globals.
Removed use of the functions math.max() and math.min() and replaced them
with and/ors:
[5000000 calls, Lua5.2]
old func: 1.37 seconds
new func: 0.53 seconds
Replaced use of the exponent operator with multiplications, yielding a
performance increase on non-JIT Lua:
[5000000 calls, Lua 5.1]
old func: 2.03 seconds
new func: 1.17 seconds
[5000000 calls, Lua 5.2]
old func: 1.60 seconds
new func: 0.89 seconds
[2000000000 calls, LuaJIT 2.0.2]
old func: 0.89 seconds
new func: 0.89 seconds
The use of a variable called "arg" was causing a bug in lume.fn() for
lua5.1 which creates a table named "arg" when a variable number of
arguments are used. The variable name has been changed to "args" to
avoid the conflict.
Fixed a bug where giving lume.slice() a negative j index (or no j index)
would not result in the correct slice -- the behaviour now correctly
matches that of string.sub() when passing a negative j index.
* The functions which lume.fn() and lume.once() return now return their
inner functions' return value instead of nil
* Moved lume.once() in lume.lua and README.md to be near its similar
functions -- lume.fn() and lume.time()
* The functions lume.any() and lume.all() now have a default function if
one is not provided -- their default behaviour with a single argument
now matches that of Python.
* Updated README.md to reflect changes
* Fixed typo in lume.any()'s example in README.md
* Incremented version revision number
Changed the lume.set(), lume.merge() and lume.filter() functions to take
the argument `retainkeys` instead of `isarray`, and to treat the table
as an array by default (avoiding sparse arrays) instead of treating the
table as an associative array by default (retaining keys).