Skip to content

Commit 47a20d3

Browse files
committed
moved the lock of map and vector
1 parent f37b719 commit 47a20d3

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

source/code2text/src/main.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,6 @@ fn gen_words(
149149
let map_data = Arc::new(Mutex::new(map));
150150

151151
lines.into_par_iter().for_each(|line| {
152-
let mut v = data.lock().unwrap();
153-
let mut map = map_data.lock().unwrap();
154-
155152
let mut scan: Scanner = Scanner::new(&line);
156153
let mut counter = 0;
157154

@@ -163,6 +160,11 @@ fn gen_words(
163160
break;
164161
}
165162
ScanResult::Ok(val1) => {
163+
164+
let mut v = data.lock().unwrap();
165+
let mut map = map_data.lock().unwrap();
166+
167+
166168
if stop && v.len() > num {
167169
break;
168170
}

0 commit comments

Comments
 (0)