4 ms·
That or specialize. Lua, Javascript, and PyPy all have more efficient storage of integer-keyed hashes. Lua's solution is particularly simple and could easily be
by obtu 15y ago
That or specialize. Lua, Javascript, and PyPy all have more efficient storage of integer-keyed hashes. Lua's solution is particularly simple and could easily be transferred to PHP.
- lysium 15y agoIn PHP you can mix the types of the key, so that won't work.
- lysium 15y agoIn another thread, dchest points out http://news.ycombinator.com/item?id=3360369 http://news.ycombinator.com/item?id=3360369 that Lua 5.0 allows mixed-typed keys, too, so that may work.
- obtu 15y agoYes. You can specialise the implementation without breaking semantics. Lua, PyPy, and some Javascript VMs are examples of that.
- deleted 15y ago[deleted]
- deleted 15y ago[deleted]
- wotnarg 15y agoYou can mix types and specialize; HipHop does. The key is that the implementation needs to be able to switch array types on the fly and convert itself. In the common case, using a specialized array will be big wins in space and time, and in the uncommon case, it can revert to a generic version.