[erlang-patches] ei patch to handle NEW_FLOAT_EXT
Serge Aleynikov
saleyn@REDACTED
Fri Jul 11 03:22:53 CEST 2008
Ever since the emulator support of the compact IEEE 754 double encoding
in external binary format was introduced I've been patiently waiting for
ei to support this feature. Finally I gave up and implemented this
myself as I recently needed to marshal lots of doubles between Erlang
and C++ and size of the binary stream did matter.
Attached is a patch for R12B-2 that implements this feature. The only
thing I wasn't sure about was whether backward compatibility of
ei_{encode,decode}_double() is truly required. It exists in the
emulator, where the new functionality is controlled by
term_to_binary(Term, [{minor_version, 1}]), and is essential indeed, but
is it really needed for ei? In order to be properly backward
compatible, it would likely require to introduce yet another pair of
functions, such as:
int ei_encode_double_new(char *buf, int *index, double p)
int ei_x_encode_double_new(ei_x_buff* x, const void *p, long len)
which gets a little messy as there are already a fair amount of ei
functions.
Since the internals of the external binary format are hidden behind the
facade of:
int ei_encode_double(char *buf, int *index, double p)
int ei_decode_double(const char *buf, int *index, double *p)
Perhaps retaining the compatibility of lower-level implementation is not
that crucial? In the patch the old functionality is controlled by
setting USE_OLD_FLOAT_ENCODER macro, but this is left discretionary to
the OTP team.
Regards,
Serge
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: ei.R12B-2.patch
URL: <http://erlang.org/pipermail/erlang-patches/attachments/20080710/d7ea316e/attachment.ksh>
More information about the erlang-patches
mailing list