Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
fmt
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
fmt
Commits
d8fd1699
Commit
d8fd1699
authored
Jul 03, 2019
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make data names follow naming conventions
parent
c286ffc8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
50 deletions
+50
-50
include/fmt/color.h
include/fmt/color.h
+7
-7
include/fmt/format-inl.h
include/fmt/format-inl.h
+16
-16
include/fmt/format.h
include/fmt/format.h
+27
-27
No files found.
include/fmt/color.h
View file @
d8fd1699
...
@@ -358,7 +358,7 @@ template <typename Char> struct ansi_color_escape {
...
@@ -358,7 +358,7 @@ template <typename Char> struct ansi_color_escape {
// If we have a terminal color, we need to output another escape code
// If we have a terminal color, we need to output another escape code
// sequence.
// sequence.
if
(
!
text_color
.
is_rgb
)
{
if
(
!
text_color
.
is_rgb
)
{
bool
is_background
=
esc
==
internal
::
data
::
BACKGROUND_COLOR
;
bool
is_background
=
esc
==
internal
::
data
::
background_color
;
uint32_t
value
=
text_color
.
value
.
term_color
;
uint32_t
value
=
text_color
.
value
.
term_color
;
// Background ASCII codes are the same as the foreground ones but with
// Background ASCII codes are the same as the foreground ones but with
// 10 more.
// 10 more.
...
@@ -430,13 +430,13 @@ template <typename Char> struct ansi_color_escape {
...
@@ -430,13 +430,13 @@ template <typename Char> struct ansi_color_escape {
template
<
typename
Char
>
template
<
typename
Char
>
FMT_CONSTEXPR
ansi_color_escape
<
Char
>
make_foreground_color
(
FMT_CONSTEXPR
ansi_color_escape
<
Char
>
make_foreground_color
(
internal
::
color_type
foreground
)
FMT_NOEXCEPT
{
internal
::
color_type
foreground
)
FMT_NOEXCEPT
{
return
ansi_color_escape
<
Char
>
(
foreground
,
internal
::
data
::
FOREGROUND_COLOR
);
return
ansi_color_escape
<
Char
>
(
foreground
,
internal
::
data
::
foreground_color
);
}
}
template
<
typename
Char
>
template
<
typename
Char
>
FMT_CONSTEXPR
ansi_color_escape
<
Char
>
make_background_color
(
FMT_CONSTEXPR
ansi_color_escape
<
Char
>
make_background_color
(
internal
::
color_type
background
)
FMT_NOEXCEPT
{
internal
::
color_type
background
)
FMT_NOEXCEPT
{
return
ansi_color_escape
<
Char
>
(
background
,
internal
::
data
::
BACKGROUND_COLOR
);
return
ansi_color_escape
<
Char
>
(
background
,
internal
::
data
::
background_color
);
}
}
template
<
typename
Char
>
template
<
typename
Char
>
...
@@ -455,17 +455,17 @@ inline void fputs<wchar_t>(const wchar_t* chars, FILE* stream) FMT_NOEXCEPT {
...
@@ -455,17 +455,17 @@ inline void fputs<wchar_t>(const wchar_t* chars, FILE* stream) FMT_NOEXCEPT {
}
}
template
<
typename
Char
>
inline
void
reset_color
(
FILE
*
stream
)
FMT_NOEXCEPT
{
template
<
typename
Char
>
inline
void
reset_color
(
FILE
*
stream
)
FMT_NOEXCEPT
{
fputs
(
internal
::
data
::
RESET_COLOR
,
stream
);
fputs
(
internal
::
data
::
reset_color
,
stream
);
}
}
template
<
>
inline
void
reset_color
<
wchar_t
>
(
FILE
*
stream
)
FMT_NOEXCEPT
{
template
<
>
inline
void
reset_color
<
wchar_t
>
(
FILE
*
stream
)
FMT_NOEXCEPT
{
fputs
(
internal
::
data
::
WRESET_COLOR
,
stream
);
fputs
(
internal
::
data
::
wreset_color
,
stream
);
}
}
template
<
typename
Char
>
template
<
typename
Char
>
inline
void
reset_color
(
basic_memory_buffer
<
Char
>&
buffer
)
FMT_NOEXCEPT
{
inline
void
reset_color
(
basic_memory_buffer
<
Char
>&
buffer
)
FMT_NOEXCEPT
{
const
char
*
begin
=
data
::
RESET_COLOR
;
const
char
*
begin
=
data
::
reset_color
;
const
char
*
end
=
begin
+
sizeof
(
data
::
RESET_COLOR
)
-
1
;
const
char
*
end
=
begin
+
sizeof
(
data
::
reset_color
)
-
1
;
buffer
.
append
(
begin
,
end
);
buffer
.
append
(
begin
,
end
);
}
}
...
...
include/fmt/format-inl.h
View file @
d8fd1699
...
@@ -255,7 +255,7 @@ int format_float(char* buf, std::size_t size, const char* format, int precision,
...
@@ -255,7 +255,7 @@ int format_float(char* buf, std::size_t size, const char* format, int precision,
}
}
template
<
typename
T
>
template
<
typename
T
>
const
char
basic_data
<
T
>::
DIGITS
[]
=
const
char
basic_data
<
T
>::
digits
[]
=
"0001020304050607080910111213141516171819"
"0001020304050607080910111213141516171819"
"2021222324252627282930313233343536373839"
"2021222324252627282930313233343536373839"
"4041424344454647484950515253545556575859"
"4041424344454647484950515253545556575859"
...
@@ -263,7 +263,7 @@ const char basic_data<T>::DIGITS[] =
...
@@ -263,7 +263,7 @@ const char basic_data<T>::DIGITS[] =
"8081828384858687888990919293949596979899"
;
"8081828384858687888990919293949596979899"
;
template
<
typename
T
>
template
<
typename
T
>
const
char
basic_data
<
T
>::
HEX_DIGITS
[]
=
"0123456789abcdef"
;
const
char
basic_data
<
T
>::
hex_digits
[]
=
"0123456789abcdef"
;
#define FMT_POWERS_OF_10(factor) \
#define FMT_POWERS_OF_10(factor) \
factor * 10, factor * 100, factor * 1000, factor * 10000, factor * 100000, \
factor * 10, factor * 100, factor * 1000, factor * 10000, factor * 100000, \
...
@@ -271,23 +271,23 @@ const char basic_data<T>::HEX_DIGITS[] = "0123456789abcdef";
...
@@ -271,23 +271,23 @@ const char basic_data<T>::HEX_DIGITS[] = "0123456789abcdef";
factor * 1000000000
factor * 1000000000
template
<
typename
T
>
template
<
typename
T
>
const
uint64_t
basic_data
<
T
>::
POWERS_OF
_10_64
[]
=
{
const
uint64_t
basic_data
<
T
>::
powers_of
_10_64
[]
=
{
1
,
FMT_POWERS_OF_10
(
1
),
FMT_POWERS_OF_10
(
1000000000ull
),
1
,
FMT_POWERS_OF_10
(
1
),
FMT_POWERS_OF_10
(
1000000000ull
),
10000000000000000000ull
};
10000000000000000000ull
};
template
<
typename
T
>
template
<
typename
T
>
const
uint32_t
basic_data
<
T
>::
ZERO_OR_POWERS_OF
_10_32
[]
=
{
0
,
const
uint32_t
basic_data
<
T
>::
zero_or_powers_of
_10_32
[]
=
{
0
,
FMT_POWERS_OF_10
(
1
)};
FMT_POWERS_OF_10
(
1
)};
template
<
typename
T
>
template
<
typename
T
>
const
uint64_t
basic_data
<
T
>::
ZERO_OR_POWERS_OF
_10_64
[]
=
{
const
uint64_t
basic_data
<
T
>::
zero_or_powers_of
_10_64
[]
=
{
0
,
FMT_POWERS_OF_10
(
1
),
FMT_POWERS_OF_10
(
1000000000ull
),
0
,
FMT_POWERS_OF_10
(
1
),
FMT_POWERS_OF_10
(
1000000000ull
),
10000000000000000000ull
};
10000000000000000000ull
};
// Normalized 64-bit significands of pow(10, k), for k = -348, -340, ..., 340.
// Normalized 64-bit significands of pow(10, k), for k = -348, -340, ..., 340.
// These are generated by support/compute-powers.py.
// These are generated by support/compute-powers.py.
template
<
typename
T
>
template
<
typename
T
>
const
uint64_t
basic_data
<
T
>::
POW10_SIGNIFICANDS
[]
=
{
const
uint64_t
basic_data
<
T
>::
pow10_significands
[]
=
{
0xfa8fd5a0081c0288
,
0xbaaee17fa23ebf76
,
0x8b16fb203055ac76
,
0xfa8fd5a0081c0288
,
0xbaaee17fa23ebf76
,
0x8b16fb203055ac76
,
0xcf42894a5dce35ea
,
0x9a6bb0aa55653b2d
,
0xe61acf033d1a45df
,
0xcf42894a5dce35ea
,
0x9a6bb0aa55653b2d
,
0xe61acf033d1a45df
,
0xab70fe17c79ac6ca
,
0xff77b1fcbebcdc4f
,
0xbe5691ef416bd60c
,
0xab70fe17c79ac6ca
,
0xff77b1fcbebcdc4f
,
0xbe5691ef416bd60c
,
...
@@ -322,7 +322,7 @@ const uint64_t basic_data<T>::POW10_SIGNIFICANDS[] = {
...
@@ -322,7 +322,7 @@ const uint64_t basic_data<T>::POW10_SIGNIFICANDS[] = {
// Binary exponents of pow(10, k), for k = -348, -340, ..., 340, corresponding
// Binary exponents of pow(10, k), for k = -348, -340, ..., 340, corresponding
// to significands above.
// to significands above.
template
<
typename
T
>
template
<
typename
T
>
const
int16_t
basic_data
<
T
>::
POW10_EXPONENTS
[]
=
{
const
int16_t
basic_data
<
T
>::
pow10_exponents
[]
=
{
-
1220
,
-
1193
,
-
1166
,
-
1140
,
-
1113
,
-
1087
,
-
1060
,
-
1034
,
-
1007
,
-
980
,
-
954
,
-
1220
,
-
1193
,
-
1166
,
-
1140
,
-
1113
,
-
1087
,
-
1060
,
-
1034
,
-
1007
,
-
980
,
-
954
,
-
927
,
-
901
,
-
874
,
-
847
,
-
821
,
-
794
,
-
768
,
-
741
,
-
715
,
-
688
,
-
661
,
-
927
,
-
901
,
-
874
,
-
847
,
-
821
,
-
794
,
-
768
,
-
741
,
-
715
,
-
688
,
-
661
,
-
635
,
-
608
,
-
582
,
-
555
,
-
529
,
-
502
,
-
475
,
-
449
,
-
422
,
-
396
,
-
369
,
-
635
,
-
608
,
-
582
,
-
555
,
-
529
,
-
502
,
-
475
,
-
449
,
-
422
,
-
396
,
-
369
,
...
@@ -333,11 +333,11 @@ const int16_t basic_data<T>::POW10_EXPONENTS[] = {
...
@@ -333,11 +333,11 @@ const int16_t basic_data<T>::POW10_EXPONENTS[] = {
827
,
853
,
880
,
907
,
933
,
960
,
986
,
1013
,
1039
,
1066
};
827
,
853
,
880
,
907
,
933
,
960
,
986
,
1013
,
1039
,
1066
};
template
<
typename
T
>
template
<
typename
T
>
const
char
basic_data
<
T
>::
FOREGROUND_COLOR
[]
=
"
\x1b
[38;2;"
;
const
char
basic_data
<
T
>::
foreground_color
[]
=
"
\x1b
[38;2;"
;
template
<
typename
T
>
template
<
typename
T
>
const
char
basic_data
<
T
>::
BACKGROUND_COLOR
[]
=
"
\x1b
[48;2;"
;
const
char
basic_data
<
T
>::
background_color
[]
=
"
\x1b
[48;2;"
;
template
<
typename
T
>
const
char
basic_data
<
T
>::
RESET_COLOR
[]
=
"
\x1b
[0m"
;
template
<
typename
T
>
const
char
basic_data
<
T
>::
reset_color
[]
=
"
\x1b
[0m"
;
template
<
typename
T
>
const
wchar_t
basic_data
<
T
>::
WRESET_COLOR
[]
=
L"
\x1b
[0m"
;
template
<
typename
T
>
const
wchar_t
basic_data
<
T
>::
wreset_color
[]
=
L"
\x1b
[0m"
;
template
<
typename
T
>
struct
bits
{
template
<
typename
T
>
struct
bits
{
static
FMT_CONSTEXPR_DECL
const
int
value
=
static
FMT_CONSTEXPR_DECL
const
int
value
=
...
@@ -455,7 +455,7 @@ FMT_FUNC fp get_cached_power(int min_exponent, int& pow10_exponent) {
...
@@ -455,7 +455,7 @@ FMT_FUNC fp get_cached_power(int min_exponent, int& pow10_exponent) {
const
int
dec_exp_step
=
8
;
const
int
dec_exp_step
=
8
;
index
=
(
index
-
first_dec_exp
-
1
)
/
dec_exp_step
+
1
;
index
=
(
index
-
first_dec_exp
-
1
)
/
dec_exp_step
+
1
;
pow10_exponent
=
first_dec_exp
+
index
*
dec_exp_step
;
pow10_exponent
=
first_dec_exp
+
index
*
dec_exp_step
;
return
fp
(
data
::
POW10_SIGNIFICANDS
[
index
],
data
::
POW10_EXPONENTS
[
index
]);
return
fp
(
data
::
pow10_significands
[
index
],
data
::
pow10_exponents
[
index
]);
}
}
enum
round_direction
{
unknown
,
up
,
down
};
enum
round_direction
{
unknown
,
up
,
down
};
...
@@ -505,7 +505,7 @@ digits::result grisu_gen_digits(fp value, uint64_t error, int& exp,
...
@@ -505,7 +505,7 @@ digits::result grisu_gen_digits(fp value, uint64_t error, int& exp,
uint64_t
fractional
=
value
.
f
&
(
one
.
f
-
1
);
uint64_t
fractional
=
value
.
f
&
(
one
.
f
-
1
);
exp
=
count_digits
(
integral
);
// kappa in Grisu.
exp
=
count_digits
(
integral
);
// kappa in Grisu.
// Divide by 10 to prevent overflow.
// Divide by 10 to prevent overflow.
auto
result
=
handler
.
on_start
(
data
::
POWERS_OF
_10_64
[
exp
-
1
]
<<
-
one
.
e
,
auto
result
=
handler
.
on_start
(
data
::
powers_of
_10_64
[
exp
-
1
]
<<
-
one
.
e
,
value
.
f
/
10
,
error
*
10
,
exp
);
value
.
f
/
10
,
error
*
10
,
exp
);
if
(
result
!=
digits
::
more
)
return
result
;
if
(
result
!=
digits
::
more
)
return
result
;
// Generate digits for the integral part. This can produce up to 10 digits.
// Generate digits for the integral part. This can produce up to 10 digits.
...
@@ -561,7 +561,7 @@ digits::result grisu_gen_digits(fp value, uint64_t error, int& exp,
...
@@ -561,7 +561,7 @@ digits::result grisu_gen_digits(fp value, uint64_t error, int& exp,
uint64_t
remainder
=
uint64_t
remainder
=
(
static_cast
<
uint64_t
>
(
integral
)
<<
-
one
.
e
)
+
fractional
;
(
static_cast
<
uint64_t
>
(
integral
)
<<
-
one
.
e
)
+
fractional
;
result
=
handler
.
on_digit
(
static_cast
<
char
>
(
'0'
+
digit
),
result
=
handler
.
on_digit
(
static_cast
<
char
>
(
'0'
+
digit
),
data
::
POWERS_OF
_10_64
[
exp
]
<<
-
one
.
e
,
remainder
,
data
::
powers_of
_10_64
[
exp
]
<<
-
one
.
e
,
remainder
,
error
,
exp
,
true
);
error
,
exp
,
true
);
if
(
result
!=
digits
::
more
)
return
result
;
if
(
result
!=
digits
::
more
)
return
result
;
}
while
(
exp
>
0
);
}
while
(
exp
>
0
);
...
@@ -658,11 +658,11 @@ template <int GRISU_VERSION> struct grisu_shortest_handler {
...
@@ -658,11 +658,11 @@ template <int GRISU_VERSION> struct grisu_shortest_handler {
buf
[
size
++
]
=
digit
;
buf
[
size
++
]
=
digit
;
if
(
remainder
>=
error
)
return
digits
::
more
;
if
(
remainder
>=
error
)
return
digits
::
more
;
if
(
GRISU_VERSION
!=
3
)
{
if
(
GRISU_VERSION
!=
3
)
{
uint64_t
d
=
integral
?
diff
:
diff
*
data
::
POWERS_OF
_10_64
[
-
exp
];
uint64_t
d
=
integral
?
diff
:
diff
*
data
::
powers_of
_10_64
[
-
exp
];
round
(
d
,
divisor
,
remainder
,
error
);
round
(
d
,
divisor
,
remainder
,
error
);
return
digits
::
done
;
return
digits
::
done
;
}
}
uint64_t
unit
=
integral
?
1
:
data
::
POWERS_OF
_10_64
[
-
exp
];
uint64_t
unit
=
integral
?
1
:
data
::
powers_of
_10_64
[
-
exp
];
uint64_t
up
=
(
diff
-
1
)
*
unit
;
// wp_Wup
uint64_t
up
=
(
diff
-
1
)
*
unit
;
// wp_Wup
round
(
up
,
divisor
,
remainder
,
error
);
round
(
up
,
divisor
,
remainder
,
error
);
uint64_t
down
=
(
diff
+
1
)
*
unit
;
// wp_Wdown
uint64_t
down
=
(
diff
+
1
)
*
unit
;
// wp_Wdown
...
...
include/fmt/format.h
View file @
d8fd1699
...
@@ -614,17 +614,17 @@ using uint32_or_64_t =
...
@@ -614,17 +614,17 @@ using uint32_or_64_t =
// Static data is placed in this class template for the header-only config.
// Static data is placed in this class template for the header-only config.
template
<
typename
T
=
void
>
struct
FMT_EXTERN_TEMPLATE_API
basic_data
{
template
<
typename
T
=
void
>
struct
FMT_EXTERN_TEMPLATE_API
basic_data
{
static
const
uint64_t
POWERS_OF
_10_64
[];
static
const
uint64_t
powers_of
_10_64
[];
static
const
uint32_t
ZERO_OR_POWERS_OF
_10_32
[];
static
const
uint32_t
zero_or_powers_of
_10_32
[];
static
const
uint64_t
ZERO_OR_POWERS_OF
_10_64
[];
static
const
uint64_t
zero_or_powers_of
_10_64
[];
static
const
uint64_t
POW10_SIGNIFICANDS
[];
static
const
uint64_t
pow10_significands
[];
static
const
int16_t
POW10_EXPONENTS
[];
static
const
int16_t
pow10_exponents
[];
static
const
char
DIGITS
[];
static
const
char
digits
[];
static
const
char
HEX_DIGITS
[];
static
const
char
hex_digits
[];
static
const
char
FOREGROUND_COLOR
[];
static
const
char
foreground_color
[];
static
const
char
BACKGROUND_COLOR
[];
static
const
char
background_color
[];
static
const
char
RESET_COLOR
[
5
];
static
const
char
reset_color
[
5
];
static
const
wchar_t
WRESET_COLOR
[
5
];
static
const
wchar_t
wreset_color
[
5
];
};
};
FMT_EXTERN
template
struct
basic_data
<
void
>;
FMT_EXTERN
template
struct
basic_data
<
void
>;
...
@@ -639,7 +639,7 @@ inline int count_digits(uint64_t n) {
...
@@ -639,7 +639,7 @@ inline int count_digits(uint64_t n) {
// Based on http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog10
// Based on http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog10
// and the benchmark https://github.com/localvoid/cxx-benchmark-count-digits.
// and the benchmark https://github.com/localvoid/cxx-benchmark-count-digits.
int
t
=
(
64
-
FMT_BUILTIN_CLZLL
(
n
|
1
))
*
1233
>>
12
;
int
t
=
(
64
-
FMT_BUILTIN_CLZLL
(
n
|
1
))
*
1233
>>
12
;
return
t
-
(
n
<
data
::
ZERO_OR_POWERS_OF
_10_64
[
t
])
+
1
;
return
t
-
(
n
<
data
::
zero_or_powers_of
_10_64
[
t
])
+
1
;
}
}
#else
#else
// Fallback version of count_digits used when __builtin_clz is not available.
// Fallback version of count_digits used when __builtin_clz is not available.
...
@@ -700,7 +700,7 @@ class decimal_formatter {
...
@@ -700,7 +700,7 @@ class decimal_formatter {
char
*
buffer_
;
char
*
buffer_
;
void
write_pair
(
unsigned
N
,
uint32_t
index
)
{
void
write_pair
(
unsigned
N
,
uint32_t
index
)
{
std
::
memcpy
(
buffer_
+
N
,
data
::
DIGITS
+
index
*
2
,
2
);
std
::
memcpy
(
buffer_
+
N
,
data
::
digits
+
index
*
2
,
2
);
}
}
public:
public:
...
@@ -717,7 +717,7 @@ class decimal_formatter {
...
@@ -717,7 +717,7 @@ class decimal_formatter {
unsigned
n
=
N
-
1
;
unsigned
n
=
N
-
1
;
unsigned
a
=
n
/
5
*
n
*
53
/
16
;
unsigned
a
=
n
/
5
*
n
*
53
/
16
;
uint64_t
t
=
uint64_t
t
=
((
1ULL
<<
(
32
+
a
))
/
data
::
ZERO_OR_POWERS_OF
_10_32
[
n
]
+
1
-
n
/
9
);
((
1ULL
<<
(
32
+
a
))
/
data
::
zero_or_powers_of
_10_32
[
n
]
+
1
-
n
/
9
);
t
=
((
t
*
u
)
>>
a
)
+
n
/
5
*
4
;
t
=
((
t
*
u
)
>>
a
)
+
n
/
5
*
4
;
write_pair
(
0
,
t
>>
32
);
write_pair
(
0
,
t
>>
32
);
for
(
unsigned
i
=
2
;
i
<
N
;
i
+=
2
)
{
for
(
unsigned
i
=
2
;
i
<
N
;
i
+=
2
)
{
...
@@ -737,7 +737,7 @@ class decimal_formatter {
...
@@ -737,7 +737,7 @@ class decimal_formatter {
// Optional version of count_digits for better performance on 32-bit platforms.
// Optional version of count_digits for better performance on 32-bit platforms.
inline
int
count_digits
(
uint32_t
n
)
{
inline
int
count_digits
(
uint32_t
n
)
{
int
t
=
(
32
-
FMT_BUILTIN_CLZ
(
n
|
1
))
*
1233
>>
12
;
int
t
=
(
32
-
FMT_BUILTIN_CLZ
(
n
|
1
))
*
1233
>>
12
;
return
t
-
(
n
<
data
::
ZERO_OR_POWERS_OF
_10_32
[
t
])
+
1
;
return
t
-
(
n
<
data
::
zero_or_powers_of
_10_32
[
t
])
+
1
;
}
}
#endif
#endif
...
@@ -766,9 +766,9 @@ inline Char* format_decimal(Char* buffer, UInt value, int num_digits,
...
@@ -766,9 +766,9 @@ inline Char* format_decimal(Char* buffer, UInt value, int num_digits,
// "Three Optimization Tips for C++". See speed-test for a comparison.
// "Three Optimization Tips for C++". See speed-test for a comparison.
unsigned
index
=
static_cast
<
unsigned
>
((
value
%
100
)
*
2
);
unsigned
index
=
static_cast
<
unsigned
>
((
value
%
100
)
*
2
);
value
/=
100
;
value
/=
100
;
*--
buffer
=
static_cast
<
Char
>
(
data
::
DIGITS
[
index
+
1
]);
*--
buffer
=
static_cast
<
Char
>
(
data
::
digits
[
index
+
1
]);
thousands_sep
(
buffer
);
thousands_sep
(
buffer
);
*--
buffer
=
static_cast
<
Char
>
(
data
::
DIGITS
[
index
]);
*--
buffer
=
static_cast
<
Char
>
(
data
::
digits
[
index
]);
thousands_sep
(
buffer
);
thousands_sep
(
buffer
);
}
}
if
(
value
<
10
)
{
if
(
value
<
10
)
{
...
@@ -776,9 +776,9 @@ inline Char* format_decimal(Char* buffer, UInt value, int num_digits,
...
@@ -776,9 +776,9 @@ inline Char* format_decimal(Char* buffer, UInt value, int num_digits,
return
end
;
return
end
;
}
}
unsigned
index
=
static_cast
<
unsigned
>
(
value
*
2
);
unsigned
index
=
static_cast
<
unsigned
>
(
value
*
2
);
*--
buffer
=
static_cast
<
Char
>
(
data
::
DIGITS
[
index
+
1
]);
*--
buffer
=
static_cast
<
Char
>
(
data
::
digits
[
index
+
1
]);
thousands_sep
(
buffer
);
thousands_sep
(
buffer
);
*--
buffer
=
static_cast
<
Char
>
(
data
::
DIGITS
[
index
]);
*--
buffer
=
static_cast
<
Char
>
(
data
::
digits
[
index
]);
return
end
;
return
end
;
}
}
...
@@ -805,7 +805,7 @@ inline Char* format_uint(Char* buffer, UInt value, int num_digits,
...
@@ -805,7 +805,7 @@ inline Char* format_uint(Char* buffer, UInt value, int num_digits,
buffer
+=
num_digits
;
buffer
+=
num_digits
;
Char
*
end
=
buffer
;
Char
*
end
=
buffer
;
do
{
do
{
const
char
*
digits
=
upper
?
"0123456789ABCDEF"
:
data
::
HEX_DIGITS
;
const
char
*
digits
=
upper
?
"0123456789ABCDEF"
:
data
::
hex_digits
;
unsigned
digit
=
(
value
&
((
1
<<
BASE_BITS
)
-
1
));
unsigned
digit
=
(
value
&
((
1
<<
BASE_BITS
)
-
1
));
*--
buffer
=
static_cast
<
Char
>
(
BASE_BITS
<
4
?
static_cast
<
char
>
(
'0'
+
digit
)
*--
buffer
=
static_cast
<
Char
>
(
BASE_BITS
<
4
?
static_cast
<
char
>
(
'0'
+
digit
)
:
digits
[
digit
]);
:
digits
[
digit
]);
...
@@ -828,7 +828,7 @@ Char* format_uint(Char* buffer, internal::fallback_uintptr n, int num_digits,
...
@@ -828,7 +828,7 @@ Char* format_uint(Char* buffer, internal::fallback_uintptr n, int num_digits,
auto
p
=
buffer
;
auto
p
=
buffer
;
for
(
int
i
=
0
;
i
<
char_digits
;
++
i
)
{
for
(
int
i
=
0
;
i
<
char_digits
;
++
i
)
{
unsigned
digit
=
(
value
&
((
1
<<
BASE_BITS
)
-
1
));
unsigned
digit
=
(
value
&
((
1
<<
BASE_BITS
)
-
1
));
*--
p
=
static_cast
<
Char
>
(
data
::
HEX_DIGITS
[
digit
]);
*--
p
=
static_cast
<
Char
>
(
data
::
hex_digits
[
digit
]);
value
>>=
BASE_BITS
;
value
>>=
BASE_BITS
;
}
}
}
}
...
@@ -972,11 +972,11 @@ template <typename Char, typename It> It write_exponent(int exp, It it) {
...
@@ -972,11 +972,11 @@ template <typename Char, typename It> It write_exponent(int exp, It it) {
if
(
exp
>=
100
)
{
if
(
exp
>=
100
)
{
*
it
++
=
static_cast
<
Char
>
(
static_cast
<
char
>
(
'0'
+
exp
/
100
));
*
it
++
=
static_cast
<
Char
>
(
static_cast
<
char
>
(
'0'
+
exp
/
100
));
exp
%=
100
;
exp
%=
100
;
const
char
*
d
=
data
::
DIGITS
+
exp
*
2
;
const
char
*
d
=
data
::
digits
+
exp
*
2
;
*
it
++
=
static_cast
<
Char
>
(
d
[
0
]);
*
it
++
=
static_cast
<
Char
>
(
d
[
0
]);
*
it
++
=
static_cast
<
Char
>
(
d
[
1
]);
*
it
++
=
static_cast
<
Char
>
(
d
[
1
]);
}
else
{
}
else
{
const
char
*
d
=
data
::
DIGITS
+
exp
*
2
;
const
char
*
d
=
data
::
digits
+
exp
*
2
;
*
it
++
=
static_cast
<
Char
>
(
d
[
0
]);
*
it
++
=
static_cast
<
Char
>
(
d
[
0
]);
*
it
++
=
static_cast
<
Char
>
(
d
[
1
]);
*
it
++
=
static_cast
<
Char
>
(
d
[
1
]);
}
}
...
@@ -2813,16 +2813,16 @@ class format_int {
...
@@ -2813,16 +2813,16 @@ class format_int {
// "Three Optimization Tips for C++". See speed-test for a comparison.
// "Three Optimization Tips for C++". See speed-test for a comparison.
unsigned
index
=
static_cast
<
unsigned
>
((
value
%
100
)
*
2
);
unsigned
index
=
static_cast
<
unsigned
>
((
value
%
100
)
*
2
);
value
/=
100
;
value
/=
100
;
*--
ptr
=
internal
::
data
::
DIGITS
[
index
+
1
];
*--
ptr
=
internal
::
data
::
digits
[
index
+
1
];
*--
ptr
=
internal
::
data
::
DIGITS
[
index
];
*--
ptr
=
internal
::
data
::
digits
[
index
];
}
}
if
(
value
<
10
)
{
if
(
value
<
10
)
{
*--
ptr
=
static_cast
<
char
>
(
'0'
+
value
);
*--
ptr
=
static_cast
<
char
>
(
'0'
+
value
);
return
ptr
;
return
ptr
;
}
}
unsigned
index
=
static_cast
<
unsigned
>
(
value
*
2
);
unsigned
index
=
static_cast
<
unsigned
>
(
value
*
2
);
*--
ptr
=
internal
::
data
::
DIGITS
[
index
+
1
];
*--
ptr
=
internal
::
data
::
digits
[
index
+
1
];
*--
ptr
=
internal
::
data
::
DIGITS
[
index
];
*--
ptr
=
internal
::
data
::
digits
[
index
];
return
ptr
;
return
ptr
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment