You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 4070 Reporter:@mmottl Status: acknowledged (set by @damiendoligez on 2006-08-29T14:59:36Z) Resolution: open Priority: normal Severity: feature Version: 3.08.4 Target version: undecided Category: runtime system and C interface Tags: patch Monitored by:@jmeber@hcarty@Chris00@mmottl
Bug description
The functions caml_frexp_float and caml_modf_float in byterun/floats.c could be implemented slightly more efficiently:
Both protect parameter "f", which is not necessary, because it is converted to a C-double before the next allocation anyway, and is not needed afterwards. Instead of "caml_alloc_tuple" it would be more efficient to use "Alloc_small", which would avoid unnecessary function calls. Finally, local value "res" does not need to be protected, because there are no allocations after it has been created.
Here are the alternative functions (untested):
CAMLprim value caml_frexp_float(value f)
{
CAMLparam0 ();
CAMLlocal1 (mantissa);
int exponent;
value res;
This issue has been open one year with no activity. Consequently, it is being marked with the "stale" label. What this means is that the issue will be automatically closed in 30 days unless more comments are added or the "stale" label is removed. Comments that provide new information on the issue are especially welcome: is it still reproducible? did it appear in other contexts? how critical is it? etc.
Original bug ID: 4070
Reporter: @mmottl
Status: acknowledged (set by @damiendoligez on 2006-08-29T14:59:36Z)
Resolution: open
Priority: normal
Severity: feature
Version: 3.08.4
Target version: undecided
Category: runtime system and C interface
Tags: patch
Monitored by: @jmeber @hcarty @Chris00 @mmottl
Bug description
The functions caml_frexp_float and caml_modf_float in byterun/floats.c could be implemented slightly more efficiently:
Both protect parameter "f", which is not necessary, because it is converted to a C-double before the next allocation anyway, and is not needed afterwards. Instead of "caml_alloc_tuple" it would be more efficient to use "Alloc_small", which would avoid unnecessary function calls. Finally, local value "res" does not need to be protected, because there are no allocations after it has been created.
Here are the alternative functions (untested):
CAMLprim value caml_frexp_float(value f)
{
CAMLparam0 ();
CAMLlocal1 (mantissa);
int exponent;
value res;
mantissa = caml_copy_double(frexp (Double_val(f), &exponent));
Alloc_small(res, 2, 0);
Field(res, 0) = mantissa;
Field(res, 1) = Val_int(exponent);
CAMLreturn (res);
}
CAMLprim value caml_modf_float(value f)
{
#if SC
_float_eval frem; /* Problem with Apple's <math.h> */
#else
double frem;
#endif
CAMLparam0 ();
CAMLlocal2 (quo, rem);
value res;
quo = caml_copy_double(modf (Double_val(f), &frem));
rem = caml_copy_double(frem);
Alloc_small(res, 2, 0);
Field(res, 0) = quo;
Field(res, 1) = rem;
CAMLreturn (res);
}
The text was updated successfully, but these errors were encountered: