1+ use slotmap:: Key ;
12use crate :: {
23 buffer:: { BufTy , GlobalBuffer } ,
34 char_info:: LexClass ,
@@ -194,10 +195,10 @@ pub(crate) fn get_bib_command_or_entry_and_process(
194195 . hash
195196 . lookup_str ( globals. pool , bib_cmd, StrIlk :: BibCommand ) ;
196197
197- let mut lc_cite_loc = 0 ;
198+ let mut lc_cite_loc = HashPointer :: default ( ) ;
198199
199200 if let Some ( loc) = res {
200- let HashExtra :: BibCommand ( cmd) = globals. hash . node ( loc) . extra else {
201+ let & HashExtra :: BibCommand ( cmd) = globals. hash . node ( loc) . extra ( ) else {
201202 panic ! ( "BibCommand lookup didn't have BibCommand extra" ) ;
202203 } ;
203204
@@ -352,13 +353,12 @@ pub(crate) fn get_bib_command_or_entry_and_process(
352353
353354 // let text = globals.hash.text(res.loc);
354355 let res = globals. hash . lookup_str_insert (
355- ctx,
356356 globals. pool ,
357357 bib_macro,
358358 HashExtra :: Macro ( StrNumber :: default ( ) ) ,
359- ) ? ;
359+ ) ;
360360 // TODO: Insert overwriting?
361- globals. hash . node_mut ( res. loc ) . extra = HashExtra :: Macro ( globals. hash . text ( res. loc ) ) ;
361+ * globals. hash . node_mut ( res. loc ) . extra_mut ( ) = HashExtra :: Macro ( globals. hash . text ( res. loc ) ) ;
362362 * cur_macro_loc = res. loc ;
363363
364364 if !eat_bib_white_space ( ctx, globals. buffers , globals. bibs ) {
@@ -444,7 +444,7 @@ pub(crate) fn get_bib_command_or_entry_and_process(
444444 . lookup_str ( globals. pool , bst_fn, StrIlk :: BstFn )
445445 . filter ( |& loc| {
446446 matches ! (
447- globals. hash. node( loc) . extra,
447+ globals. hash. node( loc) . extra( ) ,
448448 HashExtra :: BstFn ( BstFn :: Wizard ( _) )
449449 )
450450 } ) ;
@@ -515,14 +515,14 @@ pub(crate) fn get_bib_command_or_entry_and_process(
515515 let lc_res = if ctx. all_entries {
516516 globals
517517 . hash
518- . lookup_str_insert ( ctx , globals. pool , lc_cite, HashExtra :: LcCite ( 0 ) ) ?
518+ . lookup_str_insert ( globals. pool , lc_cite, HashExtra :: LcCite ( HashPointer :: default ( ) ) )
519519 } else {
520520 globals
521521 . hash
522522 . lookup_str ( globals. pool , lc_cite, StrIlk :: LcCite )
523523 . map_or (
524524 LookupRes {
525- loc : usize :: MAX ,
525+ loc : HashPointer :: default ( ) ,
526526 exists : false ,
527527 } ,
528528 |loc| LookupRes { loc, exists : true } ,
@@ -534,10 +534,10 @@ pub(crate) fn get_bib_command_or_entry_and_process(
534534 // TODO: Improve this tangled control flow
535535 let mut inner = || {
536536 if lc_res. exists {
537- let HashExtra :: LcCite ( cite_loc) = globals. hash . node ( lc_res. loc ) . extra else {
537+ let & HashExtra :: LcCite ( cite_loc) = globals. hash . node ( lc_res. loc ) . extra ( ) else {
538538 panic ! ( "LcCite lookup didn't have LcCite extra" ) ;
539539 } ;
540- let HashExtra :: Cite ( cite) = globals. hash . node ( cite_loc) . extra else {
540+ let & HashExtra :: Cite ( cite) = globals. hash . node ( cite_loc) . extra ( ) else {
541541 panic ! ( "LcCite location didn't have Cite extra" ) ;
542542 } ;
543543
@@ -547,28 +547,22 @@ pub(crate) fn get_bib_command_or_entry_and_process(
547547 || entry_ptr < globals. cites . all_marker ( )
548548 || entry_ptr > globals. cites . old_num_cites ( )
549549 {
550- if globals. cites . get_type ( entry_ptr) == 0 {
550+ if globals. cites . get_type ( entry_ptr) . is_null ( ) {
551551 if !ctx. all_entries && entry_ptr >= globals. cites . old_num_cites ( ) {
552552 let range = globals. buffers . offset ( BufTy :: Base , 1 )
553553 ..globals. buffers . offset ( BufTy :: Base , 2 ) ;
554554 let cite = & globals. buffers . buffer ( BufTy :: Base ) [ range] ;
555555 let uc_res = globals. hash . lookup_str_insert (
556- ctx,
557556 globals. pool ,
558557 cite,
559558 HashExtra :: Cite ( 0 ) ,
560559 ) ;
561560
562- let uc_res = match uc_res {
563- Ok ( res) => res,
564- Err ( e) => return Some ( Err ( e) ) ,
565- } ;
566-
567561 res = uc_res;
568562
569563 if !uc_res. exists {
570- globals. hash . node_mut ( lc_res. loc ) . extra = HashExtra :: LcCite ( uc_res. loc ) ;
571- globals. hash . node_mut ( uc_res. loc ) . extra = HashExtra :: Cite ( entry_ptr) ;
564+ * globals. hash . node_mut ( lc_res. loc ) . extra_mut ( ) = HashExtra :: LcCite ( uc_res. loc ) ;
565+ * globals. hash . node_mut ( uc_res. loc ) . extra_mut ( ) = HashExtra :: Cite ( entry_ptr) ;
572566 globals
573567 . cites
574568 . set_cite ( entry_ptr, globals. hash . text ( uc_res. loc ) ) ;
@@ -588,7 +582,7 @@ pub(crate) fn get_bib_command_or_entry_and_process(
588582 . lookup_str ( globals. pool , lc_cite, StrIlk :: LcCite )
589583 . map_or (
590584 LookupRes {
591- loc : usize :: MAX ,
585+ loc : HashPointer :: default ( ) ,
592586 exists : false ,
593587 } ,
594588 |loc| LookupRes { loc, exists : true } ,
@@ -605,7 +599,7 @@ pub(crate) fn get_bib_command_or_entry_and_process(
605599 }
606600 }
607601
608- if globals. cites . get_type ( entry_ptr) == 0 {
602+ if globals. cites . get_type ( entry_ptr) . is_null ( ) {
609603 ctx. write_logs ( "The cite list is messed up" ) ;
610604 print_confusion ( ctx) ;
611605 return Some ( Err ( BibtexError :: Fatal ) ) ;
@@ -631,7 +625,7 @@ pub(crate) fn get_bib_command_or_entry_and_process(
631625 if res. exists {
632626 if globals. cites . entry_ptr ( ) >= globals. cites . all_marker ( ) {
633627 globals. cites . set_exists ( globals. cites . entry_ptr ( ) , true ) ;
634- let HashExtra :: LcCite ( cite_loc) = globals. hash . node ( lc_res. loc ) . extra else {
628+ let & HashExtra :: LcCite ( cite_loc) = globals. hash . node ( lc_res. loc ) . extra ( ) else {
635629 panic ! ( "LcCite lookup didn't have LcCite extra" ) ;
636630 } ;
637631 globals. cites . set_entry_ptr ( globals. cites . ptr ( ) ) ;
@@ -651,7 +645,7 @@ pub(crate) fn get_bib_command_or_entry_and_process(
651645 let res =
652646 globals
653647 . hash
654- . lookup_str_insert ( ctx , globals. pool , cite, HashExtra :: Cite ( 0 ) ) ? ;
648+ . lookup_str_insert ( globals. pool , cite, HashExtra :: Cite ( 0 ) ) ;
655649 if res. exists {
656650 hash_cite_confusion ( ctx) ;
657651 return Err ( BibtexError :: Fatal ) ;
@@ -747,7 +741,7 @@ pub(crate) fn get_bib_command_or_entry_and_process(
747741 }
748742 }
749743
750- * field_name_loc = 0 ;
744+ * field_name_loc = HashPointer :: default ( ) ;
751745 let mut store_field = false ;
752746 if store_entry {
753747 let range =
@@ -760,7 +754,7 @@ pub(crate) fn get_bib_command_or_entry_and_process(
760754 match res {
761755 Some ( loc)
762756 if matches ! (
763- globals. hash. node( loc) . extra,
757+ globals. hash. node( loc) . extra( ) ,
764758 HashExtra :: BstFn ( BstFn :: Field ( _) )
765759 ) =>
766760 {
0 commit comments