Skip to content

Commit 18df9c7

Browse files
committed
Fix clippy::map_entry
1 parent d620f22 commit 18df9c7

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@
6767
#![allow(
6868
clippy::needless_range_loop,
6969
clippy::ptr_arg,
70-
clippy::map_entry,
7170
clippy::type_complexity,
7271
clippy::too_many_arguments,
7372
clippy::many_single_char_names

src/svm/svc.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -300,11 +300,12 @@ impl<'a, T: RealNumber, M: Matrix<T>, K: Kernel<T, M::RowVector>> Cache<'a, T, M
300300
fn get(&mut self, i: &SupportVector<T, M::RowVector>, j: &SupportVector<T, M::RowVector>) -> T {
301301
let idx_i = i.index;
302302
let idx_j = j.index;
303-
if !self.data.contains_key(&(idx_i, idx_j)) {
304-
let v = self.kernel.apply(&i.x, &j.x);
305-
self.data.insert((idx_i, idx_j), v);
306-
}
307-
*self.data.get(&(idx_i, idx_j)).unwrap()
303+
#[allow(clippy::or_fun_call)]
304+
let entry = self
305+
.data
306+
.entry((idx_i, idx_j))
307+
.or_insert(self.kernel.apply(&i.x, &j.x));
308+
*entry
308309
}
309310

310311
fn insert(&mut self, key: (usize, usize), value: T) {

0 commit comments

Comments
 (0)