[m-rev.] diff: use cached boxed values in java

Julien Fischer juliensf at csse.unimelb.edu.au
Tue May 11 13:12:48 AEST 2010


On Tue, 11 May 2010, Peter Wang wrote:

> Branches: main, 10.04
>
> compiler/mlds_to_java.m:
>        Use valueOf methods to get boxed values of builtin types.  valueOf
>        may return cached instances instead of creating new objects.

I think it would be worth including that rationale as a comment below.

> diff --git a/compiler/mlds_to_java.m b/compiler/mlds_to_java.m
> index 47d136d..dfa87a0 100644
> --- a/compiler/mlds_to_java.m
> +++ b/compiler/mlds_to_java.m
> @@ -4473,9 +4473,8 @@ have_preallocated_pseudo_type_var(N) :-
>
> output_boxed_rval(Info, Type, Expr, !IO) :-
>     ( java_builtin_type(Type, _JavaName, JavaBoxedName, _) ->
> -        io.write_string("new ", !IO),
>         io.write_string(JavaBoxedName, !IO),
> -        io.write_string("(", !IO),
> +        io.write_string(".valueOf(", !IO),
>         output_rval(Info, Expr, !IO),
>         io.write_string(")", !IO)

Julien.
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list