Skip to content

Commit f8a2e86

Browse files
committed
Remove outdated comments, minor control-flow improvement
1 parent 0449346 commit f8a2e86

2 files changed

Lines changed: 7 additions & 18 deletions

File tree

crates/engine_bibtex/src/bibs.rs

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,6 @@ pub(crate) fn compress_bib_white(
122122
Ok(true)
123123
}
124124

125-
// TODO: This function is unnecessarily complicated
126-
// - Most at_bib_command uses are statically known
127-
// - tied to that, command_num is only used when at_bib_command is true
128-
// - There's some messed up control flow that's porting weird `goto` style, can probably be simplified
129125
pub(crate) fn get_bib_command_or_entry_and_process(
130126
ctx: &mut Bibtex<'_, '_>,
131127
globals: &mut GlobalItems<'_>,
@@ -522,8 +518,7 @@ pub(crate) fn get_bib_command_or_entry_and_process(
522518

523519
let mut cite_exists = lc_res.exists;
524520

525-
// TODO: Improve this tangled control flow
526-
let mut inner = || {
521+
'a: {
527522
if lc_res.exists {
528523
let &cite_loc = globals.hash.get(lc_res.loc).extra();
529524
let &cite = globals.hash.get(cite_loc).extra();
@@ -556,7 +551,7 @@ pub(crate) fn get_bib_command_or_entry_and_process(
556551
}
557552
}
558553
// Break out of if
559-
return None;
554+
break 'a;
560555
}
561556
} else if !globals.cites.exists(entry_ptr) {
562557
let s = globals.pool.get_str(globals.cites.info(entry_ptr));
@@ -579,33 +574,28 @@ pub(crate) fn get_bib_command_or_entry_and_process(
579574

580575
if !lc_res2.exists {
581576
cite_key_disappeared_confusion(ctx);
582-
return Some(Err(BibtexError::Fatal));
577+
return Err(BibtexError::Fatal);
583578
}
584579
if lc_res2.loc == lc_res.loc {
585-
return None;
580+
break 'a;
586581
}
587582
}
588583

589584
if globals.cites.get_type(entry_ptr).is_null() {
590585
ctx.write_logs("The cite list is messed up");
591586
print_confusion(ctx);
592-
return Some(Err(BibtexError::Fatal));
587+
return Err(BibtexError::Fatal);
593588
}
594589

595590
ctx.write_logs("Repeated entry");
596-
return Some(bib_err_print(
591+
return bib_err_print(
597592
ctx,
598593
globals.buffers,
599594
globals.pool,
600595
globals.bibs,
601596
bib_command,
602-
));
597+
);
603598
}
604-
None
605-
};
606-
607-
if let Some(ret) = inner() {
608-
return ret;
609599
}
610600

611601
let store_entry = if ctx.all_entries {

crates/engine_bibtex/src/log.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use crate::{
55
char_info::LexClass,
66
cite::CiteInfo,
77
exec::{bst_ex_warn_print, bst_ln_num_print, ExecCtx},
8-
hash,
98
hash::{BstFn, HashData},
109
other::OtherData,
1110
peekable::input_ln,

0 commit comments

Comments
 (0)