From b727ebdb7a62e7a6346ebffac3061dc8339654c4 Mon Sep 17 00:00:00 2001 From: Andrei Alexandrescu Date: Fri, 24 Jul 2020 18:16:08 -0400 Subject: [PATCH 1/3] No need for dstrcmp in object.d --- src/object.d | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/object.d b/src/object.d index f9b711cadb..018b968bb2 100644 --- a/src/object.d +++ b/src/object.d @@ -328,14 +328,11 @@ class TypeInfo override int opCmp(Object o) { - import core.internal.string : dstrcmp; - - if (this is o) - return 0; + assert(this !is o); // __cmp takes care of that TypeInfo ti = cast(TypeInfo)o; if (ti is null) return 1; - return dstrcmp(this.toString(), ti.toString()); + return __cmp(this.toString(), ti.toString()); } override bool opEquals(Object o) @@ -3010,7 +3007,6 @@ private size_t getArrayHash(const scope TypeInfo element, const scope void* ptr, || cast(const TypeInfo_Interface) element; } - import core.internal.traits : externDFunc; if (!hasCustomToHash(element)) return hashOf(ptr[0 .. elementSize * count]); From c7224a52c23ea7e0649598838284cd667bbd573b Mon Sep 17 00:00:00 2001 From: Andrei Alexandrescu Date: Sat, 25 Jul 2020 11:03:52 -0400 Subject: [PATCH 2/3] Review --- src/object.d | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/object.d b/src/object.d index 018b968bb2..409a00ee72 100644 --- a/src/object.d +++ b/src/object.d @@ -326,10 +326,9 @@ class TypeInfo return hashOf(this.toString()); } - override int opCmp(Object o) + override int opCmp(Object rhs) { - assert(this !is o); // __cmp takes care of that - TypeInfo ti = cast(TypeInfo)o; + auto ti = cast(TypeInfo) rhs; if (ti is null) return 1; return __cmp(this.toString(), ti.toString()); From e7e5441c3d46106222d40d4c5e24fbb94743e6a1 Mon Sep 17 00:00:00 2001 From: Andrei Alexandrescu Date: Sat, 25 Jul 2020 11:26:26 -0400 Subject: [PATCH 3/3] Forgot the comparison --- src/object.d | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/object.d b/src/object.d index 409a00ee72..fa573b8ee0 100644 --- a/src/object.d +++ b/src/object.d @@ -328,6 +328,8 @@ class TypeInfo override int opCmp(Object rhs) { + if (this is rhs) + return 0; auto ti = cast(TypeInfo) rhs; if (ti is null) return 1;