mirror of
https://github.com/fmtlib/fmt.git
synced 2025-03-30 04:20:58 +00:00
Speeding up write_significand() (#2499)
This commit is contained in:
parent
26c1ca4c3e
commit
7e4bc94510
@ -1713,14 +1713,20 @@ inline auto write_significand(Char* out, UInt significand, int significand_size,
|
|||||||
int integral_size, Char decimal_point) -> Char* {
|
int integral_size, Char decimal_point) -> Char* {
|
||||||
if (!decimal_point)
|
if (!decimal_point)
|
||||||
return format_decimal(out, significand, significand_size).end;
|
return format_decimal(out, significand, significand_size).end;
|
||||||
auto end = format_decimal(out + 1, significand, significand_size).end;
|
out += significand_size + 1;
|
||||||
if (integral_size == 1) {
|
Char* end = out;
|
||||||
out[0] = out[1];
|
int floating_size = significand_size - integral_size;
|
||||||
} else {
|
for(int i = floating_size / 2; i > 0; --i) {
|
||||||
std::uninitialized_copy_n(out + 1, integral_size,
|
out -= 2;
|
||||||
make_checked(out, to_unsigned(integral_size)));
|
copy2(out, digits2(significand % 100));
|
||||||
|
significand /= 100;
|
||||||
}
|
}
|
||||||
out[integral_size] = decimal_point;
|
if (floating_size % 2 != 0) {
|
||||||
|
*--out = static_cast<Char>('0' + significand % 10);
|
||||||
|
significand /= 10;
|
||||||
|
}
|
||||||
|
*--out = decimal_point;
|
||||||
|
format_decimal(out - integral_size, significand, integral_size);
|
||||||
return end;
|
return end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user