This repository was archived by the owner on Oct 12, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ alias dstring = immutable(dchar)[];
38
38
39
39
version (D_ObjectiveC ) public import core.attribute : selector;
40
40
41
- int __cmp (T)(const T[] lhs, const T[] rhs) @trusted
41
+ int __cmp (T)(scope const T[] lhs, scope const T[] rhs) @trusted
42
42
if (__traits(isScalar, T))
43
43
{
44
44
// Compute U as the implementation type for T
@@ -69,6 +69,22 @@ int __cmp(T)(const T[] lhs, const T[] rhs) @trusted
69
69
}
70
70
else
71
71
{
72
+ version (BigEndian )
73
+ static if (__traits(isUnsigned, T) ? ! is (T == __vector ) : is (T : P* , P))
74
+ {
75
+ if (! __ctfe)
76
+ {
77
+ import core.stdc.string : memcmp;
78
+ int c = memcmp(lhs.ptr, rhs.ptr, (lhs.length <= rhs.length ? lhs.length : rhs.length) * T.sizeof);
79
+ if (c)
80
+ return c;
81
+ static if (size_t .sizeof <= uint .sizeof && T.sizeof >= 2 )
82
+ return cast (int ) lhs.length - cast (int ) rhs.length;
83
+ else
84
+ return int (lhs.length > rhs.length) - int (lhs.length < rhs.length);
85
+ }
86
+ }
87
+
72
88
immutable len = lhs.length <= rhs.length ? lhs.length : rhs.length;
73
89
foreach (const u; 0 .. len)
74
90
{
You can’t perform that action at this time.
0 commit comments