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
2e620ddb
Unverified
Commit
2e620ddb
authored
Sep 20, 2020
by
jk-jeon
Committed by
GitHub
Sep 20, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Small improvements that should have zero to negligible impact on the runtime (#1887)
parent
2f7e0885
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
14 deletions
+17
-14
include/fmt/format-inl.h
include/fmt/format-inl.h
+17
-14
No files found.
include/fmt/format-inl.h
View file @
2e620ddb
...
@@ -1870,8 +1870,8 @@ template <> struct float_info<float> {
...
@@ -1870,8 +1870,8 @@ template <> struct float_info<float> {
static
const
int
case_fc_upper_threshold
=
6
;
static
const
int
case_fc_upper_threshold
=
6
;
static
const
int
case_shorter_interval_left_endpoint_lower_threshold
=
2
;
static
const
int
case_shorter_interval_left_endpoint_lower_threshold
=
2
;
static
const
int
case_shorter_interval_left_endpoint_upper_threshold
=
3
;
static
const
int
case_shorter_interval_left_endpoint_upper_threshold
=
3
;
static
const
int
shorter_interval_
case_
tie_lower_threshold
=
-
35
;
static
const
int
shorter_interval_tie_lower_threshold
=
-
35
;
static
const
int
shorter_interval_
case_
tie_upper_threshold
=
-
35
;
static
const
int
shorter_interval_tie_upper_threshold
=
-
35
;
static
const
int
max_trailing_zeros
=
7
;
static
const
int
max_trailing_zeros
=
7
;
};
};
...
@@ -1896,8 +1896,8 @@ template <> struct float_info<double> {
...
@@ -1896,8 +1896,8 @@ template <> struct float_info<double> {
static
const
int
case_fc_upper_threshold
=
9
;
static
const
int
case_fc_upper_threshold
=
9
;
static
const
int
case_shorter_interval_left_endpoint_lower_threshold
=
2
;
static
const
int
case_shorter_interval_left_endpoint_lower_threshold
=
2
;
static
const
int
case_shorter_interval_left_endpoint_upper_threshold
=
3
;
static
const
int
case_shorter_interval_left_endpoint_upper_threshold
=
3
;
static
const
int
shorter_interval_
case_
tie_lower_threshold
=
-
77
;
static
const
int
shorter_interval_tie_lower_threshold
=
-
77
;
static
const
int
shorter_interval_
case_
tie_upper_threshold
=
-
77
;
static
const
int
shorter_interval_tie_upper_threshold
=
-
77
;
static
const
int
max_trailing_zeros
=
16
;
static
const
int
max_trailing_zeros
=
16
;
};
};
...
@@ -2061,9 +2061,10 @@ template <> struct cache_accessor<float> {
...
@@ -2061,9 +2061,10 @@ template <> struct cache_accessor<float> {
static
carrier_uint
compute_round_up_for_shorter_interval_case
(
static
carrier_uint
compute_round_up_for_shorter_interval_case
(
const
cache_entry_type
&
cache
,
int
beta_minus_1
)
FMT_NOEXCEPT
{
const
cache_entry_type
&
cache
,
int
beta_minus_1
)
FMT_NOEXCEPT
{
return
carrier_uint
(((
cache
>>
(
64
-
float_info
<
float
>::
significand_bits
-
return
(
static_cast
<
carrier_uint
>
(
2
-
beta_minus_1
))
+
cache
>>
1
))
/
(
64
-
float_info
<
float
>::
significand_bits
-
2
-
beta_minus_1
))
+
1
)
/
2
;
2
;
}
}
};
};
...
@@ -2377,8 +2378,8 @@ FMT_ALWAYS_INLINE FMT_SAFEBUFFERS void shorter_interval_case(
...
@@ -2377,8 +2378,8 @@ FMT_ALWAYS_INLINE FMT_SAFEBUFFERS void shorter_interval_case(
ret_value
.
exponent
=
minus_k
;
ret_value
.
exponent
=
minus_k
;
// When tie occurs, choose one of them according to the rule
// When tie occurs, choose one of them according to the rule
if
(
exponent
>=
float_info
<
T
>::
shorter_interval_
case_
tie_lower_threshold
&&
if
(
exponent
>=
float_info
<
T
>::
shorter_interval_tie_lower_threshold
&&
exponent
<=
float_info
<
T
>::
shorter_interval_
case_
tie_upper_threshold
)
{
exponent
<=
float_info
<
T
>::
shorter_interval_tie_upper_threshold
)
{
ret_value
.
significand
=
ret_value
.
significand
%
2
==
0
ret_value
.
significand
=
ret_value
.
significand
%
2
==
0
?
ret_value
.
significand
?
ret_value
.
significand
:
ret_value
.
significand
-
1
;
:
ret_value
.
significand
-
1
;
...
@@ -2411,7 +2412,7 @@ template <class T> FMT_SAFEBUFFERS decimal_fp<T> to_decimal(T x) FMT_NOEXCEPT {
...
@@ -2411,7 +2412,7 @@ template <class T> FMT_SAFEBUFFERS decimal_fp<T> to_decimal(T x) FMT_NOEXCEPT {
if
(
exponent
!=
0
)
{
if
(
exponent
!=
0
)
{
exponent
+=
float_info
<
T
>::
exponent_bias
-
float_info
<
T
>::
significand_bits
;
exponent
+=
float_info
<
T
>::
exponent_bias
-
float_info
<
T
>::
significand_bits
;
//
Closer boundary
case; proceed like Schubfach
//
Shorter interval
case; proceed like Schubfach
if
(
significand
==
0
)
{
if
(
significand
==
0
)
{
shorter_interval_case
<
T
>
(
ret_value
,
exponent
);
shorter_interval_case
<
T
>
(
ret_value
,
exponent
);
return
ret_value
;
return
ret_value
;
...
@@ -2461,10 +2462,12 @@ template <class T> FMT_SAFEBUFFERS decimal_fp<T> to_decimal(T x) FMT_NOEXCEPT {
...
@@ -2461,10 +2462,12 @@ template <class T> FMT_SAFEBUFFERS decimal_fp<T> to_decimal(T x) FMT_NOEXCEPT {
}
}
}
else
{
}
else
{
// r == deltai; compare fractional parts
// r == deltai; compare fractional parts
// Check conditions in the order different from the paper
// to take advantage of short-circuiting
const
carrier_uint
two_fl
=
two_fc
-
1
;
const
carrier_uint
two_fl
=
two_fc
-
1
;
if
(
!
cache_accessor
<
T
>::
compute_mul_parity
(
two_fl
,
cache
,
beta_minus_1
)
&&
if
(
(
!
include_left_endpoint
||
(
!
include_left_endpoint
||
!
is_endpoint_integer
<
T
>
(
two_fl
,
exponent
,
minus_k
))
&&
!
is_endpoint_integer
<
T
>
(
two_fl
,
exponent
,
minus_k
)
))
{
!
cache_accessor
<
T
>::
compute_mul_parity
(
two_fl
,
cache
,
beta_minus_1
))
{
goto
small_divisor_case_label
;
goto
small_divisor_case_label
;
}
}
}
}
...
@@ -2497,7 +2500,7 @@ small_divisor_case_label:
...
@@ -2497,7 +2500,7 @@ small_divisor_case_label:
// We have either yi == zi - epsiloni or yi == (zi - epsiloni) - 1,
// We have either yi == zi - epsiloni or yi == (zi - epsiloni) - 1,
// where yi == zi - epsiloni if and only if z^(f) >= epsilon^(f)
// where yi == zi - epsiloni if and only if z^(f) >= epsilon^(f)
// Since there are only 2 possibilities, we only need to care about the
// Since there are only 2 possibilities, we only need to care about the
// parity Also, zi and r should have the same parity since the divisor
// parity
.
Also, zi and r should have the same parity since the divisor
// is an even number
// is an even number
if
(
cache_accessor
<
T
>::
compute_mul_parity
(
two_fc
,
cache
,
beta_minus_1
)
!=
if
(
cache_accessor
<
T
>::
compute_mul_parity
(
two_fc
,
cache
,
beta_minus_1
)
!=
approx_y_parity
)
{
approx_y_parity
)
{
...
...
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