Skip to content

Commit

Permalink
refactor: remove unnecessary hashmap lookup
Browse files Browse the repository at this point in the history
also it turns out the break-path scenario was for some reason returning the first character of the
saved name instead of the token lol
  • Loading branch information
trag1c committed Dec 16, 2024
1 parent a8cec12 commit 21f24b9
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions src/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,7 @@ impl<'a> Core<'a> {
if let Some((s, len)) = break_path {
return Ok((
s.to_string(),
// FIXME: don't flip the hashmap every time, try caching it somewhere
if let Some(&value) = flip_hashmap(&self.tokenizer.literals).get(s.as_str()) {
value.to_string()
} else {
return Err(s.chars().next().expect("the token will never be unnamed"));
},
remaining_source.chars().take(len).collect(),
len,
));
}
Expand Down

0 comments on commit 21f24b9

Please sign in to comment.