@@ -9,8 +9,8 @@ use rustc_hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
9
9
use rustc_hir:: ItemId ;
10
10
use rustc_query_system:: ich:: StableHashingContext ;
11
11
use rustc_session:: config:: OptLevel ;
12
- use rustc_span:: source_map:: Span ;
13
12
use rustc_span:: symbol:: Symbol ;
13
+ use rustc_span:: { Span , SpanData } ;
14
14
use std:: fmt;
15
15
use std:: hash:: Hash ;
16
16
@@ -348,8 +348,10 @@ impl<'tcx> CodegenUnit<'tcx> {
348
348
) -> Vec < ( MonoItem < ' tcx > , ( Linkage , Visibility ) ) > {
349
349
// The codegen tests rely on items being process in the same order as
350
350
// they appear in the file, so for local items, we sort by span first
351
+ //
352
+ // We directly cache a SpanData to avoid having to query the interner for each comparison.
351
353
#[ derive( PartialEq , Eq , PartialOrd , Ord ) ]
352
- pub struct ItemSortKey < ' tcx > ( Option < Span > , SymbolName < ' tcx > ) ;
354
+ pub struct ItemSortKey < ' tcx > ( Option < SpanData > , SymbolName < ' tcx > ) ;
353
355
354
356
fn item_sort_key < ' tcx > ( tcx : TyCtxt < ' tcx > , item : MonoItem < ' tcx > ) -> ItemSortKey < ' tcx > {
355
357
let span = match item {
@@ -373,6 +375,7 @@ impl<'tcx> CodegenUnit<'tcx> {
373
375
MonoItem :: Static ( def_id) => tcx. hir ( ) . span_if_local ( def_id) ,
374
376
MonoItem :: GlobalAsm ( item_id) => Some ( tcx. def_span ( item_id. def_id ) ) ,
375
377
} ;
378
+ let span = span. map ( Span :: data) ;
376
379
ItemSortKey ( span, item. symbol_name ( tcx) )
377
380
}
378
381
0 commit comments