Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. COYou seem to have missed the Java tag :) If I'm not mistaken, fetching simply a dword on x86 wouldn't be all that simple, since its a little endian architecture. There are two typos in the code example (first shift should be 16 and the third array access is missing a +2 to the index). Adding that its just a condensation of whats in the question under Version1. Oh and in Java bytes are signed and silently promoted to int, so the 2nd and 3rd byte need to be masked with 0xFF.
      singulars
    2. COFirst shift is 8 bits, then 2nd byte added, and that pair is shifted left 8. If your machine has a barrel shifter, this won't matter, but if it shifts short distances faster than long it matters. Yes, dropped the +2, edited to correct. If bytes are promoted as signed (stupid Java) you can alway just copy them to "ints" before you start to avoid the sign masking junk, and that should make it competitive. Now that I've scrolled version 1 right a few hundred characters (wasnt easy where the scroll bar was) I see you did the same sort of thing. The 7 line answer got lost in your huge example :-{
      singulars
    3. CO+1 for reminding me that shift distance may make a difference on some machines. The example was once small, but the way things developed ... well it ended up this way. Unfortunately Java can not perform *any* unsigned casts to a wider type, that leaves us Java guys with no choice other than masking :(
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload