File tree 1 file changed +8
-14
lines changed 1 file changed +8
-14
lines changed Original file line number Diff line number Diff line change @@ -388,24 +388,18 @@ static void sweep_weak_refs(void)
388
388
jl_ptls_t ptls2 = gc_all_tls_states [i ];
389
389
if (ptls2 != NULL ) {
390
390
size_t n = 0 ;
391
- size_t ndel = 0 ;
391
+ size_t i = 0 ;
392
392
size_t l = ptls2 -> gc_tls_common .heap .weak_refs .len ;
393
393
void * * lst = ptls2 -> gc_tls_common .heap .weak_refs .items ;
394
- if ( l == 0 )
395
- continue ;
396
- while ( 1 ) {
397
- jl_weakref_t * wr = ( jl_weakref_t * ) lst [ n ];
398
- if ( gc_marked ( jl_astaggedvalue ( wr ) -> bits . gc ))
394
+ // filter with preserving order
395
+ for ( i = 0 ; i < l ; i ++ ) {
396
+ jl_weakref_t * wr = ( jl_weakref_t * ) lst [ i ];
397
+ if ( gc_marked ( jl_astaggedvalue ( wr ) -> bits . gc )) {
398
+ lst [ n ] = wr ;
399
399
n ++ ;
400
- else
401
- ndel ++ ;
402
- if (n >= l - ndel )
403
- break ;
404
- void * tmp = lst [n ];
405
- lst [n ] = lst [n + ndel ];
406
- lst [n + ndel ] = tmp ;
400
+ }
407
401
}
408
- ptls2 -> gc_tls_common .heap .weak_refs .len -= ndel ;
402
+ ptls2 -> gc_tls_common .heap .weak_refs .len = n ;
409
403
}
410
404
}
411
405
}
You can’t perform that action at this time.
0 commit comments