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
ba363b3a
Commit
ba363b3a
authored
Jun 27, 2020
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use digit pairs as in unrolledlut
parent
a6f8e7d8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
11 deletions
+28
-11
include/fmt/format-inl.h
include/fmt/format-inl.h
+21
-6
include/fmt/format.h
include/fmt/format.h
+7
-5
No files found.
include/fmt/format-inl.h
View file @
ba363b3a
...
@@ -239,12 +239,27 @@ template <> FMT_FUNC int count_digits<4>(detail::fallback_uintptr n) {
...
@@ -239,12 +239,27 @@ template <> FMT_FUNC int count_digits<4>(detail::fallback_uintptr n) {
}
}
template
<
typename
T
>
template
<
typename
T
>
const
char
basic_data
<
T
>::
digits
[]
=
const
typename
basic_data
<
T
>::
digit_pair
basic_data
<
T
>::
digits
[]
=
{
"0001020304050607080910111213141516171819"
{
'0'
,
'0'
},
{
'0'
,
'1'
},
{
'0'
,
'2'
},
{
'0'
,
'3'
},
{
'0'
,
'4'
},
"2021222324252627282930313233343536373839"
{
'0'
,
'5'
},
{
'0'
,
'6'
},
{
'0'
,
'7'
},
{
'0'
,
'8'
},
{
'0'
,
'9'
},
"4041424344454647484950515253545556575859"
{
'1'
,
'0'
},
{
'1'
,
'1'
},
{
'1'
,
'2'
},
{
'1'
,
'3'
},
{
'1'
,
'4'
},
"6061626364656667686970717273747576777879"
{
'1'
,
'5'
},
{
'1'
,
'6'
},
{
'1'
,
'7'
},
{
'1'
,
'8'
},
{
'1'
,
'9'
},
"8081828384858687888990919293949596979899"
;
{
'2'
,
'0'
},
{
'2'
,
'1'
},
{
'2'
,
'2'
},
{
'2'
,
'3'
},
{
'2'
,
'4'
},
{
'2'
,
'5'
},
{
'2'
,
'6'
},
{
'2'
,
'7'
},
{
'2'
,
'8'
},
{
'2'
,
'9'
},
{
'3'
,
'0'
},
{
'3'
,
'1'
},
{
'3'
,
'2'
},
{
'3'
,
'3'
},
{
'3'
,
'4'
},
{
'3'
,
'5'
},
{
'3'
,
'6'
},
{
'3'
,
'7'
},
{
'3'
,
'8'
},
{
'3'
,
'9'
},
{
'4'
,
'0'
},
{
'4'
,
'1'
},
{
'4'
,
'2'
},
{
'4'
,
'3'
},
{
'4'
,
'4'
},
{
'4'
,
'5'
},
{
'4'
,
'6'
},
{
'4'
,
'7'
},
{
'4'
,
'8'
},
{
'4'
,
'9'
},
{
'5'
,
'0'
},
{
'5'
,
'1'
},
{
'5'
,
'2'
},
{
'5'
,
'3'
},
{
'5'
,
'4'
},
{
'5'
,
'5'
},
{
'5'
,
'6'
},
{
'5'
,
'7'
},
{
'5'
,
'8'
},
{
'5'
,
'9'
},
{
'6'
,
'0'
},
{
'6'
,
'1'
},
{
'6'
,
'2'
},
{
'6'
,
'3'
},
{
'6'
,
'4'
},
{
'6'
,
'5'
},
{
'6'
,
'6'
},
{
'6'
,
'7'
},
{
'6'
,
'8'
},
{
'6'
,
'9'
},
{
'7'
,
'0'
},
{
'7'
,
'1'
},
{
'7'
,
'2'
},
{
'7'
,
'3'
},
{
'7'
,
'4'
},
{
'7'
,
'5'
},
{
'7'
,
'6'
},
{
'7'
,
'7'
},
{
'7'
,
'8'
},
{
'7'
,
'9'
},
{
'8'
,
'0'
},
{
'8'
,
'1'
},
{
'8'
,
'2'
},
{
'8'
,
'3'
},
{
'8'
,
'4'
},
{
'8'
,
'5'
},
{
'8'
,
'6'
},
{
'8'
,
'7'
},
{
'8'
,
'8'
},
{
'8'
,
'9'
},
{
'9'
,
'0'
},
{
'9'
,
'1'
},
{
'9'
,
'2'
},
{
'9'
,
'3'
},
{
'9'
,
'4'
},
{
'9'
,
'5'
},
{
'9'
,
'6'
},
{
'9'
,
'7'
},
{
'9'
,
'8'
},
{
'9'
,
'9'
}};
template
<
typename
T
>
template
<
typename
T
>
const
char
basic_data
<
T
>::
hex_digits
[]
=
"0123456789abcdef"
;
const
char
basic_data
<
T
>::
hex_digits
[]
=
"0123456789abcdef"
;
...
...
include/fmt/format.h
View file @
ba363b3a
...
@@ -752,7 +752,9 @@ template <typename T = void> struct FMT_EXTERN_TEMPLATE_API basic_data {
...
@@ -752,7 +752,9 @@ template <typename T = void> struct FMT_EXTERN_TEMPLATE_API basic_data {
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
[];
// GCC generates slightly better code for pairs than chars.
using
digit_pair
=
char
[
2
];
static
const
digit_pair
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
[];
...
@@ -903,7 +905,7 @@ inline format_decimal_result<Char*> format_decimal(Char* out, UInt value,
...
@@ -903,7 +905,7 @@ inline format_decimal_result<Char*> format_decimal(Char* out, UInt value,
// of for every digit. The idea comes from the talk by Alexandrescu
// of for every digit. The idea comes from the talk by Alexandrescu
// "Three Optimization Tips for C++". See speed-test for a comparison.
// "Three Optimization Tips for C++". See speed-test for a comparison.
out
-=
2
;
out
-=
2
;
copy2
(
out
,
data
::
digits
+
static_cast
<
unsigned
>
((
value
%
100
)
*
2
)
);
copy2
(
out
,
data
::
digits
[
value
%
100
]
);
value
/=
100
;
value
/=
100
;
}
}
if
(
value
<
10
)
{
if
(
value
<
10
)
{
...
@@ -911,7 +913,7 @@ inline format_decimal_result<Char*> format_decimal(Char* out, UInt value,
...
@@ -911,7 +913,7 @@ inline format_decimal_result<Char*> format_decimal(Char* out, UInt value,
return
{
out
,
end
};
return
{
out
,
end
};
}
}
out
-=
2
;
out
-=
2
;
copy2
(
out
,
data
::
digits
+
static_cast
<
unsigned
>
(
value
*
2
)
);
copy2
(
out
,
data
::
digits
[
value
]
);
return
{
out
,
end
};
return
{
out
,
end
};
}
}
...
@@ -1085,12 +1087,12 @@ template <typename Char, typename It> It write_exponent(int exp, It it) {
...
@@ -1085,12 +1087,12 @@ template <typename Char, typename It> It write_exponent(int exp, It it) {
*
it
++
=
static_cast
<
Char
>
(
'+'
);
*
it
++
=
static_cast
<
Char
>
(
'+'
);
}
}
if
(
exp
>=
100
)
{
if
(
exp
>=
100
)
{
const
char
*
top
=
data
::
digits
+
(
exp
/
100
)
*
2
;
const
char
*
top
=
data
::
digits
[
exp
/
100
]
;
if
(
exp
>=
1000
)
*
it
++
=
static_cast
<
Char
>
(
top
[
0
]);
if
(
exp
>=
1000
)
*
it
++
=
static_cast
<
Char
>
(
top
[
0
]);
*
it
++
=
static_cast
<
Char
>
(
top
[
1
]);
*
it
++
=
static_cast
<
Char
>
(
top
[
1
]);
exp
%=
100
;
exp
%=
100
;
}
}
const
char
*
d
=
data
::
digits
+
exp
*
2
;
const
char
*
d
=
data
::
digits
[
exp
]
;
*
it
++
=
static_cast
<
Char
>
(
d
[
0
]);
*
it
++
=
static_cast
<
Char
>
(
d
[
0
]);
*
it
++
=
static_cast
<
Char
>
(
d
[
1
]);
*
it
++
=
static_cast
<
Char
>
(
d
[
1
]);
return
it
;
return
it
;
...
...
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