File tree 2 files changed +20
-13
lines changed
crates/next-core/src/next_app
turbopack/crates/turbo-tasks/src
2 files changed +20
-13
lines changed Original file line number Diff line number Diff line change
1
+ use std:: cmp:: Ordering ;
2
+
1
3
use anyhow:: Result ;
2
4
use futures:: join;
3
5
use tracing:: Instrument ;
@@ -429,6 +431,7 @@ fn reorder_isolated_merged_entries(
429
431
else {
430
432
unreachable ! ( "expected ChunkGroup::IsolatedMerged for client reference" )
431
433
} ;
434
+
432
435
// Reorder the entries, because the order of IsolatedMerged entries obtained by chunk_group_info
433
436
// is unspecified (and thus not strictly execution order, which is a problem for CSS).
434
437
//
@@ -437,18 +440,17 @@ fn reorder_isolated_merged_entries(
437
440
// matter in this case (since they will not be chunked in this step anyway).
438
441
439
442
if entries. iter ( ) . any ( |m| client_to_ref_ty. contains_key ( m) ) {
440
- let entries = client_to_ref_ty
441
- . keys ( )
442
- . copied ( )
443
- . filter ( |m| entries. contains ( m) )
444
- . chain (
445
- entries
446
- . iter ( )
447
- . copied ( )
448
- . filter ( |m| !client_to_ref_ty. contains_key ( m) ) ,
449
- )
450
- . collect ( ) ;
451
-
443
+ let mut entries = entries. clone ( ) ;
444
+ entries. sort_by ( |a, b| {
445
+ match (
446
+ client_to_ref_ty. get_index_of ( a) ,
447
+ client_to_ref_ty. get_index_of ( b) ,
448
+ ) {
449
+ ( Some ( a) , Some ( b) ) => a. cmp ( & b) ,
450
+ // We don't know, so just keep the same order.
451
+ _ => Ordering :: Equal ,
452
+ }
453
+ } ) ;
452
454
Some ( ChunkGroup :: IsolatedMerged {
453
455
parent : * parent,
454
456
entries,
Original file line number Diff line number Diff line change 1
1
use std:: {
2
2
hash:: { BuildHasher , Hash } ,
3
- ops:: Deref ,
3
+ ops:: { Deref , DerefMut } ,
4
4
time:: Duration ,
5
5
} ;
6
6
@@ -91,6 +91,11 @@ impl<T: Hash + Eq> Deref for HashableIndexSet<T> {
91
91
& self . 0
92
92
}
93
93
}
94
+ impl < T : Hash + Eq > DerefMut for HashableIndexSet < T > {
95
+ fn deref_mut ( & mut self ) -> & mut Self :: Target {
96
+ & mut self . 0
97
+ }
98
+ }
94
99
impl < T : Hash + Eq > Hash for HashableIndexSet < T > {
95
100
fn hash < H : std:: hash:: Hasher > ( & self , state : & mut H ) {
96
101
let mut result = 0u64 ;
You can’t perform that action at this time.
0 commit comments