Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

Commit b93ba68

Browse files
authored
Merge pull request #151 from 4tm4j33tk4ur/clippy
fixed some clippy warnings
2 parents 1e551a6 + ee6c046 commit b93ba68

27 files changed

+78
-92
lines changed

src/math/acos.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const QS4: f64 = 7.70381505559019352791e-02; /* 0x3FB3B8C5, 0xB12E9282 */
5252
fn r(z: f64) -> f64 {
5353
let p: f64 = z * (PS0 + z * (PS1 + z * (PS2 + z * (PS3 + z * (PS4 + z * PS5)))));
5454
let q: f64 = 1.0 + z * (QS1 + z * (QS2 + z * (QS3 + z * QS4)));
55-
return p / q;
55+
p / q
5656
}
5757

5858
#[inline]
@@ -73,7 +73,7 @@ pub fn acos(x: f64) -> f64 {
7373
if ix >= 0x3ff00000 {
7474
let lx: u32 = x.to_bits() as u32;
7575

76-
if (ix - 0x3ff00000 | lx) == 0 {
76+
if ((ix - 0x3ff00000) | lx) == 0 {
7777
/* acos(1)=0, acos(-1)=pi */
7878
if (hx >> 31) != 0 {
7979
return 2. * PIO2_HI + x1p_120f;
@@ -105,5 +105,5 @@ pub fn acos(x: f64) -> f64 {
105105

106106
c = (z - df * df) / (s + df);
107107
w = r(z) * s + c;
108-
return 2. * (df + w);
108+
2. * (df + w)
109109
}

src/math/asin.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ const Q_S4: f64 = 7.70381505559019352791e-02; /* 0x3FB3B8C5, 0xB12E9282 */
5959
fn comp_r(z: f64) -> f64 {
6060
let p = z * (P_S0 + z * (P_S1 + z * (P_S2 + z * (P_S3 + z * (P_S4 + z * P_S5)))));
6161
let q = 1.0 + z * (Q_S1 + z * (Q_S2 + z * (Q_S3 + z * Q_S4)));
62-
return p / q;
62+
p / q
6363
}
6464

6565
#[inline]
@@ -77,7 +77,7 @@ pub fn asin(mut x: f64) -> f64 {
7777
if ix >= 0x3ff00000 {
7878
let lx: u32;
7979
lx = get_low_word(x);
80-
if (ix - 0x3ff00000 | lx) == 0 {
80+
if ((ix - 0x3ff00000) | lx) == 0 {
8181
/* asin(1) = +-pi/2 with inexact */
8282
return x * PIO2_HI + f64::from_bits(0x3870000000000000);
8383
} else {
@@ -109,8 +109,8 @@ pub fn asin(mut x: f64) -> f64 {
109109
x = 0.5 * PIO2_HI - (2.0 * s * r - (PIO2_LO - 2.0 * c) - (0.5 * PIO2_HI - 2.0 * f));
110110
}
111111
if hx >> 31 != 0 {
112-
return -x;
112+
-x
113113
} else {
114-
return x;
114+
x
115115
}
116116
}

src/math/atan.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,16 +102,14 @@ pub fn atan(x: f64) -> f64 {
102102
x = (x - 1.) / (x + 1.);
103103
1
104104
}
105+
} else if ix < 0x40038000 {
106+
/* |x| < 2.4375 */
107+
x = (x - 1.5) / (1. + 1.5 * x);
108+
2
105109
} else {
106-
if ix < 0x40038000 {
107-
/* |x| < 2.4375 */
108-
x = (x - 1.5) / (1. + 1.5 * x);
109-
2
110-
} else {
111-
/* 2.4375 <= |x| < 2^66 */
112-
x = -1. / x;
113-
3
114-
}
110+
/* 2.4375 <= |x| < 2^66 */
111+
x = -1. / x;
112+
3
115113
}
116114
};
117115

src/math/atan2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ pub fn atan2(y: f64, x: f64) -> f64 {
5353
let lx = x.to_bits() as u32;
5454
let mut iy = (y.to_bits() >> 32) as u32;
5555
let ly = y.to_bits() as u32;
56-
if (ix - 0x3ff00000 | lx) == 0 {
56+
if ((ix - 0x3ff00000) | lx) == 0 {
5757
/* x = 1.0 */
5858
return atan(y);
5959
}

src/math/atanf.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,14 @@ pub fn atanf(mut x: f32) -> f32 {
8080
x = (x - 1.) / (x + 1.);
8181
1
8282
}
83+
} else if ix < 0x401c0000 {
84+
/* |x| < 2.4375 */
85+
x = (x - 1.5) / (1. + 1.5 * x);
86+
2
8387
} else {
84-
if ix < 0x401c0000 {
85-
/* |x| < 2.4375 */
86-
x = (x - 1.5) / (1. + 1.5 * x);
87-
2
88-
} else {
89-
/* 2.4375 <= |x| < 2**26 */
90-
x = -1. / x;
91-
3
92-
}
88+
/* 2.4375 <= |x| < 2**26 */
89+
x = -1. / x;
90+
3
9391
}
9492
};
9593
/* end of argument reduction */

src/math/ceil.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub fn ceil(x: f64) -> f64 {
2727
x + TOINT - TOINT - x
2828
};
2929
// special case because of non-nearest rounding modes
30-
if e <= 0x3ff - 1 {
30+
if e < 0x3ff {
3131
force_eval!(y);
3232
return if (u >> 63) != 0 { -0. } else { 1. };
3333
}

src/math/ceilf.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@ pub fn ceilf(x: f32) -> f32 {
3535
return 1.0;
3636
}
3737
}
38-
return f32::from_bits(ui);
38+
f32::from_bits(ui)
3939
}

src/math/cosf.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,25 +50,21 @@ pub fn cosf(x: f32) -> f32 {
5050
if ix > 0x4016cbe3 {
5151
/* |x| ~> 3*pi/4 */
5252
return -k_cosf(if sign { x64 + C2_PIO2 } else { x64 - C2_PIO2 });
53+
} else if sign {
54+
return k_sinf(x64 + C1_PIO2);
5355
} else {
54-
if sign {
55-
return k_sinf(x64 + C1_PIO2);
56-
} else {
57-
return k_sinf(C1_PIO2 - x64);
58-
}
56+
return k_sinf(C1_PIO2 - x64);
5957
}
6058
}
6159
if ix <= 0x40e231d5 {
6260
/* |x| ~<= 9*pi/4 */
6361
if ix > 0x40afeddf {
6462
/* |x| ~> 7*pi/4 */
6563
return k_cosf(if sign { x64 + C4_PIO2 } else { x64 - C4_PIO2 });
64+
} else if sign {
65+
return k_sinf(-x64 - C3_PIO2);
6666
} else {
67-
if sign {
68-
return k_sinf(-x64 - C3_PIO2);
69-
} else {
70-
return k_sinf(x64 - C3_PIO2);
71-
}
67+
return k_sinf(x64 - C3_PIO2);
7268
}
7369
}
7470

src/math/expo2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ pub fn expo2(x: f64) -> f64 {
1111
/* note that k is odd and scale*scale overflows */
1212
let scale = combine_words(((0x3ff + K / 2) as u32) << 20, 0);
1313
/* exp(x - k ln2) * 2**(k-1) */
14-
return exp(x - kln2) * scale * scale;
14+
exp(x - kln2) * scale * scale
1515
}

src/math/fdim.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@ pub fn fdim(x: f64, y: f64) -> f64 {
77
x
88
} else if y.is_nan() {
99
y
10+
} else if x > y {
11+
x - y
1012
} else {
11-
if x > y {
12-
x - y
13-
} else {
14-
0.0
15-
}
13+
0.0
1614
}
1715
}

0 commit comments

Comments
 (0)