[m-rev.] diff: slightly speed up string equality for java
Peter Wang
novalazy at gmail.com
Mon Mar 15 16:18:38 AEDT 2010
Branches: main, 10.04
compiler/mlds_to_java.m:
Use `equals' method for string equality as it is slightly faster than
`compareTo'.
diff --git a/compiler/mlds_to_java.m b/compiler/mlds_to_java.m
index 593da87..8a2e29a 100644
--- a/compiler/mlds_to_java.m
+++ b/compiler/mlds_to_java.m
@@ -4477,13 +4477,20 @@ output_binop(Info, Op, X, Y, !IO) :-
output_rval(Info, Y, !IO),
io.write_string("]", !IO)
; java_string_compare_op(Op, OpStr) ->
- io.write_string("(", !IO),
- output_rval(Info, X, !IO),
- io.write_string(".compareTo(", !IO),
- output_rval(Info, Y, !IO),
- io.write_string(") ", !IO),
- io.write_string(OpStr, !IO),
- io.write_string(" 0)", !IO)
+ ( OpStr = "==" ->
+ output_rval(Info, X, !IO),
+ io.write_string(".equals(", !IO),
+ output_rval(Info, Y, !IO),
+ io.write_string(")", !IO)
+ ;
+ io.write_string("(", !IO),
+ output_rval(Info, X, !IO),
+ io.write_string(".compareTo(", !IO),
+ output_rval(Info, Y, !IO),
+ io.write_string(") ", !IO),
+ io.write_string(OpStr, !IO),
+ io.write_string(" 0)", !IO)
+ )
; rval_is_enum_object(X) ->
io.write_string("(", !IO),
output_rval(Info, X, !IO),
--------------------------------------------------------------------------
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