diff --git a/static_core/irtoc/scripts/string_helpers.irt b/static_core/irtoc/scripts/string_helpers.irt index c3663a76637db848a462797cbaff5d440865ef73..0dcddf83042fbe72019cf2e42c66e49682455110 100644 --- a/static_core/irtoc/scripts/string_helpers.irt +++ b/static_core/irtoc/scripts/string_helpers.irt @@ -173,6 +173,16 @@ def GenerateStringEquals(lang, dynamic, compression, cgmode = :FastPath) Return(res).b Label(:Long) + hashcode1 := LoadI(str1).Imm(Constants::STRING_HASHCODE_OFFSET).u32 + If(hashcode1, 0).NE.b { + hashcode2 := LoadI(str2).Imm(Constants::STRING_HASHCODE_OFFSET).u32 + If(hashcode2, 0).NE.b { + If(hashcode1, hashcode2).NE.b { + Goto(:NotEqual) + } + } + } + unroll := Compare(length, 64).GE.b IfImm(unroll).Imm(0).SrcType("DataType::BOOL").NE.b { if cgmode == :NativePlus diff --git a/static_core/plugins/ets/stdlib/std/core/Runtime.ets b/static_core/plugins/ets/stdlib/std/core/Runtime.ets index 63bcf5fcdba12731beb1b48932feee873cd09048..0cac6ec14858dbf5244ea9997cc689260f4f1355 100644 --- a/static_core/plugins/ets/stdlib/std/core/Runtime.ets +++ b/static_core/plugins/ets/stdlib/std/core/Runtime.ets @@ -60,6 +60,8 @@ export final class Runtime { if (o1 instanceof Number && o2 instanceof Number) { return Runtime.sameNumberValue(o1 as Number, o2 as Number) + } else if (o1 instanceof String && o2 instanceof String) { + return (o1 as String).equals(o2) // same semantics as ==, but faster } else if (o1 instanceof Float && o2 instanceof Float) { return Runtime.sameFloatValue(o1 as Float, o2 as Float) }