Skip to content

Commit

Permalink
update code to early return
Browse files Browse the repository at this point in the history
  • Loading branch information
raphamorim committed Sep 11, 2024
1 parent 001f219 commit c8ed19c
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions sugarloaf/src/layout/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,14 +533,15 @@ impl WordCache {
#[inline]
pub fn finish(&mut self) {
// println!("{:?} {:?}", self.key, self.inner.len());
if !self.key.is_empty() && !self.stash.is_empty() {
if self.inner.get(&self.key).is_none() {
self.inner.put(
std::mem::take(&mut self.key),
std::mem::take(&mut self.stash),
);
return;
}
if !self.key.is_empty()
&& !self.stash.is_empty()
&& self.inner.get(&self.key).is_none()
{
self.inner.put(
std::mem::take(&mut self.key),
std::mem::take(&mut self.stash),
);
return;
}
self.stash.clear();
self.key.clear();
Expand Down

0 comments on commit c8ed19c

Please sign in to comment.