Remove std.conv import from quickSortImpl

This commit is contained in:
0-v-0 2024-06-22 11:07:40 +08:00
parent 42e2caa5c0
commit d8e8f1f351
2 changed files with 8 additions and 7 deletions

View file

@ -2164,12 +2164,12 @@ private void quickSortImpl(alias less, Range)(Range r, size_t depth)
{
import std.algorithm.comparison : min, max;
import std.algorithm.mutation : swap, swapAt;
import std.conv : to;
alias Elem = ElementType!(Range);
enum size_t shortSortGetsBetter = max(32, 1024 / Elem.sizeof);
enum int size = Elem.sizeof;
enum size_t shortSortGetsBetter = max(32, 1024 / size);
static assert(shortSortGetsBetter >= 1, Elem.stringof ~ " "
~ to!string(Elem.sizeof));
~ size.stringof);
// partition
while (r.length > shortSortGetsBetter)

View file

@ -161,15 +161,16 @@ if (isInputRange!Range && isSomeChar!T && !is(T == enum) && isSomeChar!(ElementT
enforceFmt(find(acceptedSpecs!T, spec.spec).length,
text("Wrong unformat specifier '%", spec.spec , "' for ", T.stringof));
static if (T.sizeof == 1)
enum int size = T.sizeof;
static if (size == 1)
return unformatValue!ubyte(input, spec);
else static if (T.sizeof == 2)
else static if (size == 2)
return unformatValue!ushort(input, spec);
else static if (T.sizeof == 4)
else static if (size == 4)
return unformatValue!uint(input, spec);
else
static assert(false, T.stringof ~ ".sizeof must be 1, 2, or 4 not " ~
to!string(T.sizeof));
size.stringof);
}
T unformatValueImpl(T, Range, Char)(ref Range input, scope const ref FormatSpec!Char fmt)