diff options
-rw-r--r-- | byterun/str.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/byterun/str.c b/byterun/str.c index 79e4ef81b..380e2eb5a 100644 --- a/byterun/str.c +++ b/byterun/str.c @@ -67,9 +67,12 @@ CAMLprim value caml_string_set(value str, value index, value newval) CAMLprim value caml_string_equal(value s1, value s2) { - mlsize_t sz1 = Wosize_val(s1); - mlsize_t sz2 = Wosize_val(s2); + mlsize_t sz1, sz2; value * p1, * p2; + + if (s1 == s2) return Val_true; + sz1 = Wosize_val(s1); + sz2 = Wosize_val(s2); if (sz1 != sz2) return Val_false; for(p1 = Op_val(s1), p2 = Op_val(s2); sz1 > 0; sz1--, p1++, p2++) if (*p1 != *p2) return Val_false; @@ -86,6 +89,7 @@ CAMLprim value caml_string_compare(value s1, value s2) mlsize_t len1, len2; int res; + if (s1 == s2) return Val_int(0); len1 = caml_string_length(s1); len2 = caml_string_length(s2); res = memcmp(String_val(s1), String_val(s2), len1 <= len2 ? len1 : len2); |