mirror of
https://github.com/fmtlib/fmt.git
synced 2025-01-12 15:39:09 +00:00
PrepareFilledBuffer -> PrepareBufferForInt
This commit is contained in:
parent
c556926597
commit
512ab9336b
16
format.h
16
format.h
@ -859,7 +859,7 @@ class BasicWriter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Prepare a buffer for integer formatting.
|
// Prepare a buffer for integer formatting.
|
||||||
CharPtr PrepareFilledBuffer(unsigned num_digits,
|
CharPtr PrepareBufferForInt(unsigned num_digits,
|
||||||
const EmptySpec &, const char *prefix, unsigned prefix_size) {
|
const EmptySpec &, const char *prefix, unsigned prefix_size) {
|
||||||
unsigned size = prefix_size + num_digits;
|
unsigned size = prefix_size + num_digits;
|
||||||
CharPtr p = GrowBuffer(size);
|
CharPtr p = GrowBuffer(size);
|
||||||
@ -868,7 +868,7 @@ class BasicWriter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename Spec>
|
template <typename Spec>
|
||||||
CharPtr PrepareFilledBuffer(unsigned num_digits,
|
CharPtr PrepareBufferForInt(unsigned num_digits,
|
||||||
const Spec &spec, const char *prefix, unsigned prefix_size);
|
const Spec &spec, const char *prefix, unsigned prefix_size);
|
||||||
|
|
||||||
// Formats an integer.
|
// Formats an integer.
|
||||||
@ -1306,7 +1306,7 @@ typename BasicWriter<Char>::CharPtr BasicWriter<Char>::FormatString(
|
|||||||
template <typename Char>
|
template <typename Char>
|
||||||
template <typename Spec>
|
template <typename Spec>
|
||||||
typename fmt::BasicWriter<Char>::CharPtr
|
typename fmt::BasicWriter<Char>::CharPtr
|
||||||
fmt::BasicWriter<Char>::PrepareFilledBuffer(
|
fmt::BasicWriter<Char>::PrepareBufferForInt(
|
||||||
unsigned num_digits, const Spec &spec,
|
unsigned num_digits, const Spec &spec,
|
||||||
const char *prefix, unsigned prefix_size) {
|
const char *prefix, unsigned prefix_size) {
|
||||||
unsigned width = spec.width();
|
unsigned width = spec.width();
|
||||||
@ -1323,7 +1323,7 @@ typename fmt::BasicWriter<Char>::CharPtr
|
|||||||
std::fill(p, p + size, spec.fill());
|
std::fill(p, p + size, spec.fill());
|
||||||
// TODO: take alignment into account
|
// TODO: take alignment into account
|
||||||
}
|
}
|
||||||
return PrepareFilledBuffer(num_digits,
|
return PrepareBufferForInt(num_digits,
|
||||||
AlignSpec(number_size, '0', ALIGN_NUMERIC), prefix, prefix_size);
|
AlignSpec(number_size, '0', ALIGN_NUMERIC), prefix, prefix_size);
|
||||||
}
|
}
|
||||||
unsigned size = prefix_size + num_digits;
|
unsigned size = prefix_size + num_digits;
|
||||||
@ -1378,7 +1378,7 @@ void BasicWriter<Char>::FormatInt(T value, const Spec &spec) {
|
|||||||
switch (spec.type()) {
|
switch (spec.type()) {
|
||||||
case 0: case 'd': {
|
case 0: case 'd': {
|
||||||
unsigned num_digits = internal::CountDigits(abs_value);
|
unsigned num_digits = internal::CountDigits(abs_value);
|
||||||
CharPtr p = PrepareFilledBuffer(
|
CharPtr p = PrepareBufferForInt(
|
||||||
num_digits, spec, prefix, prefix_size) + 1 - num_digits;
|
num_digits, spec, prefix, prefix_size) + 1 - num_digits;
|
||||||
internal::FormatDecimal(GetBase(p), abs_value, num_digits);
|
internal::FormatDecimal(GetBase(p), abs_value, num_digits);
|
||||||
break;
|
break;
|
||||||
@ -1393,7 +1393,7 @@ void BasicWriter<Char>::FormatInt(T value, const Spec &spec) {
|
|||||||
do {
|
do {
|
||||||
++num_digits;
|
++num_digits;
|
||||||
} while ((n >>= 4) != 0);
|
} while ((n >>= 4) != 0);
|
||||||
Char *p = GetBase(PrepareFilledBuffer(
|
Char *p = GetBase(PrepareBufferForInt(
|
||||||
num_digits, spec, prefix, prefix_size));
|
num_digits, spec, prefix, prefix_size));
|
||||||
n = abs_value;
|
n = abs_value;
|
||||||
const char *digits = spec.type() == 'x' ?
|
const char *digits = spec.type() == 'x' ?
|
||||||
@ -1413,7 +1413,7 @@ void BasicWriter<Char>::FormatInt(T value, const Spec &spec) {
|
|||||||
do {
|
do {
|
||||||
++num_digits;
|
++num_digits;
|
||||||
} while ((n >>= 1) != 0);
|
} while ((n >>= 1) != 0);
|
||||||
Char *p = GetBase(PrepareFilledBuffer(num_digits, spec, prefix, prefix_size));
|
Char *p = GetBase(PrepareBufferForInt(num_digits, spec, prefix, prefix_size));
|
||||||
n = abs_value;
|
n = abs_value;
|
||||||
do {
|
do {
|
||||||
*p-- = '0' + (n & 1);
|
*p-- = '0' + (n & 1);
|
||||||
@ -1428,7 +1428,7 @@ void BasicWriter<Char>::FormatInt(T value, const Spec &spec) {
|
|||||||
do {
|
do {
|
||||||
++num_digits;
|
++num_digits;
|
||||||
} while ((n >>= 3) != 0);
|
} while ((n >>= 3) != 0);
|
||||||
Char *p = GetBase(PrepareFilledBuffer(
|
Char *p = GetBase(PrepareBufferForInt(
|
||||||
num_digits, spec, prefix, prefix_size));
|
num_digits, spec, prefix, prefix_size));
|
||||||
n = abs_value;
|
n = abs_value;
|
||||||
do {
|
do {
|
||||||
|
Loading…
Reference in New Issue
Block a user