Skip to content

Commit b93ba68

Browse files
authored
Merge pull request rust-lang#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
}

src/math/fdimf.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@ pub fn fdimf(x: f32, y: f32) -> f32 {
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
}

src/math/floor.rs

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

src/math/floorf.rs

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

4141
#[cfg(test)]

src/math/fma.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,15 @@ pub fn fma(x: f64, y: f64, z: f64) -> f64 {
8383
if d > 0 {
8484
if d < 64 {
8585
zlo = nz.m << d;
86-
zhi = nz.m >> 64 - d;
86+
zhi = nz.m >> (64 - d);
8787
} else {
8888
zlo = 0;
8989
zhi = nz.m;
9090
e = nz.e - 64;
9191
d -= 64;
9292
if d == 0 {
9393
} else if d < 64 {
94-
rlo = rhi << 64 - d | rlo >> d | ((rlo << 64 - d) != 0) as u64;
94+
rlo = rhi << (64 - d) | rlo >> d | ((rlo << (64 - d)) != 0) as u64;
9595
rhi = rhi >> d;
9696
} else {
9797
rlo = 1;
@@ -104,7 +104,7 @@ pub fn fma(x: f64, y: f64, z: f64) -> f64 {
104104
if d == 0 {
105105
zlo = nz.m;
106106
} else if d < 64 {
107-
zlo = nz.m >> d | ((nz.m << 64 - d) != 0) as u64;
107+
zlo = nz.m >> d | ((nz.m << (64 - d)) != 0) as u64;
108108
} else {
109109
zlo = 1;
110110
}
@@ -136,7 +136,7 @@ pub fn fma(x: f64, y: f64, z: f64) -> f64 {
136136
e += 64;
137137
d = rhi.leading_zeros() as i32 - 1;
138138
/* note: d > 0 */
139-
rhi = rhi << d | rlo >> 64 - d | ((rlo << d) != 0) as u64;
139+
rhi = rhi << d | rlo >> (64 - d) | ((rlo << d) != 0) as u64;
140140
} else if rlo != 0 {
141141
d = rlo.leading_zeros() as i32 - 1;
142142
if d < 0 {
@@ -191,7 +191,7 @@ pub fn fma(x: f64, y: f64, z: f64) -> f64 {
191191
} else {
192192
/* only round once when scaled */
193193
d = 10;
194-
i = ((rhi >> d | ((rhi << 64 - d) != 0) as u64) << d) as i64;
194+
i = ((rhi >> d | ((rhi << (64 - d)) != 0) as u64) << d) as i64;
195195
if sign != 0 {
196196
i = -i;
197197
}

src/math/hypot.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,5 @@ pub fn hypot(mut x: f64, mut y: f64) -> f64 {
7272
}
7373
let (hx, lx) = sq(x);
7474
let (hy, ly) = sq(y);
75-
return z * sqrt(ly + lx + hy + hx);
75+
z * sqrt(ly + lx + hy + hx)
7676
}

src/math/log.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,5 +114,5 @@ pub fn log(mut x: f64) -> f64 {
114114
let t2: f64 = z * (LG1 + w * (LG3 + w * (LG5 + w * LG7)));
115115
let r: f64 = t2 + t1;
116116
let dk: f64 = k as f64;
117-
return s * (hfsq + r) + dk * LN2_LO - hfsq + f + dk * LN2_HI;
117+
s * (hfsq + r) + dk * LN2_LO - hfsq + f + dk * LN2_HI
118118
}

src/math/log10.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,5 +114,5 @@ pub fn log10(mut x: f64) -> f64 {
114114
val_lo += (y - w) + val_hi;
115115
val_hi = w;
116116

117-
return val_lo + val_hi;
117+
val_lo + val_hi
118118
}

src/math/log10f.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,5 +88,5 @@ pub fn log10f(mut x: f32) -> f32 {
8888
hi = f32::from_bits(ui);
8989
lo = f - hi - hfsq + s * (hfsq + r);
9090
dk = k as f32;
91-
return dk * LOG10_2LO + (lo + hi) * IVLN10LO + lo * IVLN10HI + hi * IVLN10HI + dk * LOG10_2HI;
91+
dk * LOG10_2LO + (lo + hi) * IVLN10LO + lo * IVLN10HI + hi * IVLN10HI + dk * LOG10_2HI
9292
}

src/math/log1p.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,5 +140,5 @@ pub fn log1p(x: f64) -> f64 {
140140
t2 = z * (LG1 + w * (LG3 + w * (LG5 + w * LG7)));
141141
r = t2 + t1;
142142
dk = k as f64;
143-
return s * (hfsq + r) + (dk * LN2_LO + c) - hfsq + f + dk * LN2_HI;
143+
s * (hfsq + r) + (dk * LN2_LO + c) - hfsq + f + dk * LN2_HI
144144
}

src/math/log1pf.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,5 +95,5 @@ pub fn log1pf(x: f32) -> f32 {
9595
r = t2 + t1;
9696
hfsq = 0.5 * f * f;
9797
dk = k as f32;
98-
return s * (hfsq + r) + (dk * LN2_LO + c) - hfsq + f + dk * LN2_HI;
98+
s * (hfsq + r) + (dk * LN2_LO + c) - hfsq + f + dk * LN2_HI
9999
}

src/math/log2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,5 +103,5 @@ pub fn log2(mut x: f64) -> f64 {
103103
val_lo += (y - w) + val_hi;
104104
val_hi = w;
105105

106-
return val_lo + val_hi;
106+
val_lo + val_hi
107107
}

src/math/log2f.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,5 +84,5 @@ pub fn log2f(mut x: f32) -> f32 {
8484
ui &= 0xfffff000;
8585
hi = f32::from_bits(ui);
8686
lo = f - hi - hfsq + s * (hfsq + r);
87-
return (lo + hi) * IVLN2LO + lo * IVLN2HI + hi * IVLN2HI + k as f32;
87+
(lo + hi) * IVLN2LO + lo * IVLN2HI + hi * IVLN2HI + k as f32
8888
}

src/math/pow.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ pub fn pow(x: f64, y: f64) -> f64 {
406406
z = with_set_high_word(z, j as u32);
407407
}
408408

409-
return s * z;
409+
s * z
410410
}
411411

412412
#[cfg(test)]

src/math/powf.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,12 @@ pub fn powf(x: f32, y: f32) -> f32 {
136136
return x * x;
137137
}
138138

139-
if hy == 0x3f000000 {
140-
/* y is 0.5 */
141-
if hx >= 0 {
142-
/* x >= +0 */
143-
return sqrtf(x);
144-
}
139+
if hy == 0x3f000000
140+
/* y is 0.5 */
141+
&& hx >= 0
142+
{
143+
/* x >= +0 */
144+
return sqrtf(x);
145145
}
146146

147147
ax = fabsf(x);
@@ -296,11 +296,11 @@ pub fn powf(x: f32, y: f32) -> f32 {
296296
/* z < -150 */
297297
// FIXME: check should be (uint32_t)j > 0xc3160000
298298
return sn * TINY * TINY; /* underflow */
299-
} else if j as u32 == 0xc3160000 {
300-
/* z == -150 */
301-
if p_l <= z - p_h {
302-
return sn * TINY * TINY; /* underflow */
303-
}
299+
} else if j as u32 == 0xc3160000
300+
/* z == -150 */
301+
&& p_l <= z - p_h
302+
{
303+
return sn * TINY * TINY; /* underflow */
304304
}
305305

306306
/*
@@ -339,5 +339,5 @@ pub fn powf(x: f32, y: f32) -> f32 {
339339
} else {
340340
z = f32::from_bits(j as u32);
341341
}
342-
return sn * z;
342+
sn * z
343343
}

0 commit comments

Comments
 (0)