|
1 | 1 | use std::{
|
| 2 | + cmp::Ordering, |
2 | 3 | collections::{HashMap, hash_map},
|
3 | 4 | hash::{BuildHasherDefault, Hash, Hasher},
|
4 | 5 | };
|
@@ -289,20 +290,20 @@ impl SplitChunksPlugin {
|
289 | 290 | &self,
|
290 | 291 | module_group_map: &mut ModuleGroupMap,
|
291 | 292 | ) -> (String, ModuleGroup) {
|
292 |
| - // perf(hyf): I wonder if we could use BinaryHeap to avoid sorting for find_best_module_group call |
293 | 293 | debug_assert!(!module_group_map.is_empty());
|
294 |
| - let mut iter: std::collections::hash_map::Iter<String, ModuleGroup> = module_group_map.iter(); |
295 |
| - let (key, mut best_module_group) = iter.next().expect("at least have one item"); |
296 |
| - |
297 |
| - let mut best_entry_key = key; |
298 |
| - for (key, each_module_group) in iter { |
299 |
| - if compare_entries(best_module_group, each_module_group) < 0f64 { |
300 |
| - best_entry_key = key; |
301 |
| - best_module_group = each_module_group; |
302 |
| - } |
303 |
| - } |
304 | 294 |
|
305 |
| - let best_entry_key = best_entry_key.clone(); |
| 295 | + let best_entry_key = module_group_map |
| 296 | + .iter() |
| 297 | + .min_by(|a, b| { |
| 298 | + if compare_entries(a.1, b.1) < 0f64 { |
| 299 | + Ordering::Greater |
| 300 | + } else { |
| 301 | + Ordering::Less |
| 302 | + } |
| 303 | + }) |
| 304 | + .map(|(key, _)| key.clone()) |
| 305 | + .expect("at least have one item"); |
| 306 | + |
306 | 307 | let best_module_group = module_group_map
|
307 | 308 | .remove(&best_entry_key)
|
308 | 309 | .expect("This should never happen, please file an issue");
|
@@ -480,8 +481,7 @@ impl SplitChunksPlugin {
|
480 | 481 | ) {
|
481 | 482 | // remove all modules from other entries and update size
|
482 | 483 | let keys_of_invalid_group = module_group_map
|
483 |
| - .iter_mut() |
484 |
| - .par_bridge() |
| 484 | + .par_iter_mut() |
485 | 485 | .filter_map(|(key, other_module_group)| {
|
486 | 486 | other_module_group
|
487 | 487 | .chunks
|
|
0 commit comments