@@ -4,7 +4,8 @@ use crate::{
44 char_info:: LexClass ,
55 cite:: CiteInfo ,
66 exec:: print_bst_name,
7- hash:: { HashData , HashExtra } ,
7+ hash,
8+ hash:: { HashData , HashPointer } ,
89 log:: {
910 aux_end1_err_print, aux_end2_err_print, aux_err_illegal_another_print,
1011 aux_err_no_right_brace_print, aux_err_print, aux_err_stuff_after_right_brace_print,
@@ -15,7 +16,7 @@ use crate::{
1516 peekable:: PeekableInput ,
1617 pool:: { StrNumber , StringPool } ,
1718 scan:: Scan ,
18- Bibtex , BibtexError , File , GlobalItems , StrIlk ,
19+ Bibtex , BibtexError , File , GlobalItems ,
1920} ;
2021use std:: ffi:: CString ;
2122use tectonic_bridge_core:: FileFormat ;
@@ -105,27 +106,27 @@ fn aux_bib_data_command(
105106
106107 let file = & buffers. buffer ( BufTy :: Base )
107108 [ buffers. offset ( BufTy :: Base , 1 ) ..buffers. offset ( BufTy :: Base , 2 ) ] ;
108- let res = hash. lookup_str_insert ( ctx , pool, file, HashExtra :: BibFile ) ? ;
109+ let res = hash. lookup_str_insert :: < hash :: BibFile > ( pool, file, ( ) ) ;
109110 if res. exists {
110111 ctx. write_logs ( "This database file appears more than once: " ) ;
111- print_bib_name ( ctx, pool, hash. text ( res. loc ) ) ?;
112+ print_bib_name ( ctx, pool, hash. get ( res. loc ) . text ( ) ) ?;
112113 aux_err_print ( ctx, buffers, aux, pool) ?;
113114 return Ok ( ( ) ) ;
114115 }
115116
116- let name = pool. get_str ( hash. text ( res. loc ) ) ;
117+ let name = pool. get_str ( hash. get ( res. loc ) . text ( ) ) ;
117118 let fname = CString :: new ( name) . unwrap ( ) ;
118119 let bib_in = PeekableInput :: open ( ctx, & fname, FileFormat :: Bib ) ;
119120 match bib_in {
120121 Err ( _) => {
121122 ctx. write_logs ( "I couldn't open database file " ) ;
122- print_bib_name ( ctx, pool, hash. text ( res. loc ) ) ?;
123+ print_bib_name ( ctx, pool, hash. get ( res. loc ) . text ( ) ) ?;
123124 aux_err_print ( ctx, buffers, aux, pool) ?;
124125 return Ok ( ( ) ) ;
125126 }
126127 Ok ( file) => {
127128 bibs. push_file ( File {
128- name : hash. text ( res. loc ) ,
129+ name : hash. get ( res. loc ) . text ( ) ,
129130 file,
130131 line : 0 ,
131132 } ) ;
@@ -176,27 +177,27 @@ fn aux_bib_style_command(
176177
177178 let file = & buffers. buffer ( BufTy :: Base )
178179 [ buffers. offset ( BufTy :: Base , 1 ) ..buffers. offset ( BufTy :: Base , 2 ) ] ;
179- let res = hash. lookup_str_insert ( ctx , pool, file, HashExtra :: BstFile ) ? ;
180+ let res = hash. lookup_str_insert :: < hash :: BstFile > ( pool, file, ( ) ) ;
180181 if res. exists {
181182 ctx. write_logs ( "Already encountered style file" ) ;
182183 print_confusion ( ctx) ;
183184 return Err ( BibtexError :: Fatal ) ;
184185 }
185186
186- let name = pool. get_str ( hash. text ( res. loc ) ) ;
187+ let name = pool. get_str ( hash. get ( res. loc ) . text ( ) ) ;
187188 let fname = CString :: new ( name) . unwrap ( ) ;
188189 let bst_file = PeekableInput :: open ( ctx, & fname, FileFormat :: Bst ) ;
189190 match bst_file {
190191 Err ( _) => {
191192 ctx. write_logs ( "I couldn't open style file " ) ;
192- print_bst_name ( ctx, pool, hash. text ( res. loc ) ) ?;
193+ print_bst_name ( ctx, pool, hash. get ( res. loc ) . text ( ) ) ?;
193194 ctx. bst = None ;
194195 aux_err_print ( ctx, buffers, aux, pool) ?;
195196 return Ok ( ( ) ) ;
196197 }
197198 Ok ( file) => {
198199 ctx. bst = Some ( File {
199- name : hash. text ( res. loc ) ,
200+ name : hash. get ( res. loc ) . text ( ) ,
200201 file,
201202 line : 0 ,
202203 } ) ;
@@ -276,20 +277,15 @@ fn aux_citation_command(
276277 let lc_cite = & mut buffers. buffer_mut ( BufTy :: Ex ) [ range] ;
277278 lc_cite. make_ascii_lowercase ( ) ;
278279
279- let lc_res = hash. lookup_str_insert ( ctx , pool, lc_cite, HashExtra :: LcCite ( 0 ) ) ? ;
280+ let lc_res = hash. lookup_str_insert :: < hash :: LcCite > ( pool, lc_cite, HashPointer :: default ( ) ) ;
280281 if lc_res. exists {
281- let HashExtra :: LcCite ( cite_loc) = hash. node ( lc_res. loc ) . extra else {
282- panic ! ( "LcCite lookup didn't have LcCite extra" ) ;
283- } ;
282+ let & cite_loc = hash. get ( lc_res. loc ) . extra ( ) ;
284283
285284 let cite = & buffers. buffer ( BufTy :: Base )
286285 [ buffers. offset ( BufTy :: Base , 1 ) ..buffers. offset ( BufTy :: Base , 2 ) ] ;
287- let uc_res = hash. lookup_str ( pool, cite, StrIlk :: Cite ) ;
288- if !uc_res. exists {
289- let HashExtra :: Cite ( cite) = hash. node ( cite_loc) . extra else {
290- panic ! ( "LcCite location didn't have a Cite extra" ) ;
291- } ;
292-
286+ let uc_res = hash. lookup_str :: < hash:: Cite > ( pool, cite) ;
287+ if uc_res. is_none ( ) {
288+ let & cite = hash. get ( cite_loc) . extra ( ) ;
293289 ctx. write_logs ( "Case mismatch error between cite keys " ) ;
294290 print_a_token ( ctx, buffers) ;
295291 ctx. write_logs ( " and " ) ;
@@ -301,7 +297,7 @@ fn aux_citation_command(
301297 } else {
302298 let cite = & buffers. buffer ( BufTy :: Base )
303299 [ buffers. offset ( BufTy :: Base , 1 ) ..buffers. offset ( BufTy :: Base , 2 ) ] ;
304- let uc_res = hash. lookup_str_insert ( ctx , pool, cite, HashExtra :: Cite ( 0 ) ) ? ;
300+ let uc_res = hash. lookup_str_insert :: < hash :: Cite > ( pool, cite, 0 ) ;
305301 if uc_res. exists {
306302 hash_cite_confusion ( ctx) ;
307303 return Err ( BibtexError :: Fatal ) ;
@@ -311,9 +307,9 @@ fn aux_citation_command(
311307 cites. grow ( ) ;
312308 }
313309
314- cites. set_cite ( cites. ptr ( ) , hash. text ( uc_res. loc ) ) ;
315- hash. node_mut ( uc_res. loc ) . extra = HashExtra :: Cite ( cites. ptr ( ) ) ;
316- hash. node_mut ( lc_res. loc ) . extra = HashExtra :: LcCite ( uc_res. loc ) ;
310+ cites. set_cite ( cites. ptr ( ) , hash. get ( uc_res. loc ) . text ( ) ) ;
311+ hash. set_extra ( uc_res. loc , cites. ptr ( ) ) ;
312+ hash. set_extra ( lc_res. loc , uc_res. loc ) ;
317313 cites. set_ptr ( cites. ptr ( ) + 1 ) ;
318314 }
319315 }
@@ -375,27 +371,27 @@ fn aux_input_command(
375371
376372 let file = & buffers. buffer ( BufTy :: Base )
377373 [ buffers. offset ( BufTy :: Base , 1 ) ..buffers. offset ( BufTy :: Base , 2 ) ] ;
378- let res = hash. lookup_str_insert ( ctx , pool, file, HashExtra :: AuxFile ) ? ;
374+ let res = hash. lookup_str_insert :: < hash :: AuxFile > ( pool, file, ( ) ) ;
379375 if res. exists {
380376 ctx. write_logs ( "Already encountered file " ) ;
381- print_aux_name ( ctx, pool, hash. text ( res. loc ) ) ?;
377+ print_aux_name ( ctx, pool, hash. get ( res. loc ) . text ( ) ) ?;
382378 aux_err_print ( ctx, buffers, aux, pool) ?;
383379 return Ok ( ( ) ) ;
384380 }
385381
386- let name = pool. get_str ( hash. text ( res. loc ) ) ;
382+ let name = pool. get_str ( hash. get ( res. loc ) . text ( ) ) ;
387383 let fname = CString :: new ( name) . unwrap ( ) ;
388384 let file = PeekableInput :: open ( ctx, & fname, FileFormat :: Tex ) ;
389385 match file {
390386 Err ( _) => {
391387 ctx. write_logs ( "I couldn't open auxiliary file " ) ;
392- print_aux_name ( ctx, pool, hash. text ( res. loc ) ) ?;
388+ print_aux_name ( ctx, pool, hash. get ( res. loc ) . text ( ) ) ?;
393389 aux_err_print ( ctx, buffers, aux, pool) ?;
394390 return Ok ( ( ) ) ;
395391 }
396392 Ok ( file) => {
397393 aux. push_file ( File {
398- name : hash. text ( res. loc ) ,
394+ name : hash. get ( res. loc ) . text ( ) ,
399395 file,
400396 line : 0 ,
401397 } ) ;
@@ -420,14 +416,10 @@ pub(crate) fn get_aux_command_and_process(
420416
421417 let line = & globals. buffers . buffer ( BufTy :: Base )
422418 [ globals. buffers . offset ( BufTy :: Base , 1 ) ..globals. buffers . offset ( BufTy :: Base , 2 ) ] ;
423- let res = globals
424- . hash
425- . lookup_str ( globals. pool , line, StrIlk :: AuxCommand ) ;
419+ let res = globals. hash . lookup_str :: < AuxCommand > ( globals. pool , line) ;
426420
427- if res. exists {
428- let HashExtra :: AuxCommand ( cmd) = globals. hash . node ( res. loc ) . extra else {
429- panic ! ( "AuxCommand lookup didn't have AuxCommand extra" ) ;
430- } ;
421+ if let Some ( loc) = res {
422+ let & cmd = globals. hash . get ( loc) . extra ( ) ;
431423
432424 match cmd {
433425 AuxCommand :: Data => aux_bib_data_command (
0 commit comments