Utility function microoptimizations

Cycle with numbers instead of ipairs and other minor tweakings in an
attempt to improve performance. The gain is honestly negligible.
Length functions microoptimizations

The functions present in length.lua are called many times... an attempt
to optimize them was sensible. The gain is negligible on PUC Lua,
though.