Skip to content

Commit daad8a1

Browse files
committed
Eliminate obsolete casts
Signed-off-by: netthier <[email protected]>
1 parent 17053d2 commit daad8a1

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

src/contourbuilder.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,15 @@ impl ContourBuilder {
8686
let xt = x.trunc() as usize;
8787
let yt = y.trunc() as usize;
8888
let mut v0;
89-
let ix = (yt * dx + xt) as usize;
89+
let ix = yt * dx + xt;
9090
if ix < len_values {
9191
let v1 = values[ix];
9292
if x > 0.0 && x < (dx as Float) && (xt as Float - x).abs() < Float::EPSILON {
93-
v0 = values[(yt * dx + xt - 1) as usize];
93+
v0 = values[yt * dx + xt - 1];
9494
point.x = x + (value - v0) / (v1 - v0) - 0.5;
9595
}
9696
if y > 0.0 && y < (dy as Float) && (yt as Float - y).abs() < Float::EPSILON {
97-
v0 = values[((yt - 1) * dx + xt) as usize];
97+
v0 = values[(yt - 1) * dx + xt];
9898
point.y = y + (value - v0) / (v1 - v0) - 0.5;
9999
}
100100
}

src/isoringbuilder.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -113,54 +113,54 @@ impl IsoRingBuilder {
113113
let mut t3;
114114

115115
// Special case for the first row (y = -1, t2 = t3 = 0).
116-
t1 = (values[0] >= threshold) as u32;
117-
case_stitch!((t1 << 1) as usize, x, y, &mut result);
116+
t1 = (values[0] >= threshold) as usize;
117+
case_stitch!(t1 << 1, x, y, &mut result);
118118
x += 1;
119119
while x < dx - 1 {
120120
t0 = t1;
121-
t1 = (values[(x + 1) as usize] >= threshold) as u32;
122-
case_stitch!((t0 | t1 << 1) as usize, x, y, &mut result);
121+
t1 = (values[(x + 1) as usize] >= threshold) as usize;
122+
case_stitch!(t0 | t1 << 1, x, y, &mut result);
123123
x += 1;
124124
}
125-
case_stitch!(t1 as usize, x, y, &mut result);
125+
case_stitch!(t1, x, y, &mut result);
126126

127127
// General case for the intermediate rows.
128128
y += 1;
129129
while y < dy - 1 {
130130
x = -1;
131-
t1 = (values[(y * dx + dx) as usize] >= threshold) as u32;
132-
t2 = (values[(y * dx) as usize] >= threshold) as u32;
133-
case_stitch!((t1 << 1 | t2 << 2) as usize, x, y, &mut result);
131+
t1 = (values[(y * dx + dx) as usize] >= threshold) as usize;
132+
t2 = (values[(y * dx) as usize] >= threshold) as usize;
133+
case_stitch!(t1 << 1 | t2 << 2, x, y, &mut result);
134134
x += 1;
135135
while x < dx - 1 {
136136
t0 = t1;
137-
t1 = (values[(y * dx + dx + x + 1) as usize] >= threshold) as u32;
137+
t1 = (values[(y * dx + dx + x + 1) as usize] >= threshold) as usize;
138138
t3 = t2;
139-
t2 = (values[(y * dx + x + 1) as usize] >= threshold) as u32;
139+
t2 = (values[(y * dx + x + 1) as usize] >= threshold) as usize;
140140
case_stitch!(
141-
(t0 | t1 << 1 | t2 << 2 | t3 << 3) as usize,
141+
t0 | t1 << 1 | t2 << 2 | t3 << 3,
142142
x,
143143
y,
144144
&mut result
145145
);
146146
x += 1;
147147
}
148-
case_stitch!((t1 | t2 << 3) as usize, x, y, &mut result);
148+
case_stitch!(t1 | t2 << 3, x, y, &mut result);
149149
y += 1;
150150
}
151151

152152
// Special case for the last row (y = dy - 1, t0 = t1 = 0).
153153
x = -1;
154-
t2 = (values[(y * dx) as usize] >= threshold) as u32;
155-
case_stitch!((t2 << 2) as usize, x, y, &mut result);
154+
t2 = (values[(y * dx) as usize] >= threshold) as usize;
155+
case_stitch!(t2 << 2, x, y, &mut result);
156156
x += 1;
157157
while x < dx - 1 {
158158
t3 = t2;
159-
t2 = (values[(y * dx + x + 1) as usize] >= threshold) as u32;
160-
case_stitch!((t2 << 2 | t3 << 3) as usize, x, y, &mut result);
159+
t2 = (values[(y * dx + x + 1) as usize] >= threshold) as usize;
160+
case_stitch!(t2 << 2 | t3 << 3, x, y, &mut result);
161161
x += 1;
162162
}
163-
case_stitch!((t2 << 3) as usize, x, y, &mut result);
163+
case_stitch!(t2 << 3, x, y, &mut result);
164164
self.is_empty = false;
165165
Ok(result)
166166
}

0 commit comments

Comments
 (0)