lua-users home
lua-l archive

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


Mike Pall <mikelu-1106 <at> mike.de> writes:
> For the bytecode I'm already delta-encoding most values and use a
> couple of other tricks to reduce their range. So the majority of
> values for the ULEB128 encoding fit into 0-127 and only need a
> single byte. Then it _is_ faster to do this:
> 
>   v = *p++;
>   if (LJ_UNLIKELY(v >= 0x80)) { ... decode the remaining bytes ... }
>   return v

The scheme I mentioned has exactly the same encoding for values
0-127, so the code for the 1-byte case could be identical.  The only
difference is for multi-byte values (ie. the "...decode the remaining
bytes..." part.)

But if it's extremely rare to have values of more than one or two
bytes, it probably won't make a difference in the end.

Josh