Now compare that with freaking BB decoding, sweep, mark,slice, get,
apply & 0xFF for handling sign.. and if you want to extract a bunch of
structured data in 1 pass, it's impossible.
I think the problem is the way you implement decoder in Java using the
ByteBuffer abstraction, the way we extract structured data .
Agreed. For Java, what we can ask is just 'which abstraction is
better?' My point is to separate state information from data. Like we
did in C with malloc(). Using ByteBuffer is like changing the value of
the return value of malloc() not storing its initial value in that
position and limit can be changed whenever user wants.
Not sure I get the analogy. Malloc just returns a pointer on a memory
area, you are free, as a user, to move this pointer back and forth, it's
up to you to be sure you don't step out of the area... Java is much more
defensive, and when you do that, you get an OOB exception quickly.
I would say that it's up to the user to deal with this problem unless
you provide a copy of the buffer as a byte[] (and with direct buffer,
this will be costly). So if we provide such a layer, be sure that
experienced users can still hit the underlying BB without passing
through another API
--
--
cordialement, regards,
Emmanuel Lécharny
www.iktek.com
directory.apache.org