File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed
Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -248,9 +248,17 @@ impl<T: Clone> Dict<T> {
248248 if let Some ( index) = entry_index. index ( ) {
249249 // Update existing key
250250 if let Some ( entry) = inner. entries . get_mut ( index) {
251- let entry = entry
252- . as_mut ( )
253- . expect ( "The dict was changed since we did lookup." ) ;
251+ let entry = if let Some ( entry) = entry. as_mut ( ) {
252+ entry
253+ } else {
254+ // The dict was changed since we did lookup. Let's try again.
255+ // this is very rare to happen
256+ // (and seems only happen with very high freq gc, and about three to four time in 200000 iters)
257+ // but still possible
258+ // so logging a warn is acceptable in here
259+ warn ! ( "The dict was changed since we did lookup. Let's try again." ) ;
260+ continue ;
261+ } ;
254262 if entry. index == index_index {
255263 let removed = std:: mem:: replace ( & mut entry. value , value) ;
256264 // defer dec RC
You can’t perform that action at this time.
0 commit comments