Skip to content

Commit

Permalink
fix push_front/push_back mixup
Browse files Browse the repository at this point in the history
  • Loading branch information
skius committed Aug 10, 2023
1 parent dc8dda7 commit 9d55038
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
4 changes: 3 additions & 1 deletion docs/tutorials/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions experimental/transliterator_parser/src/compile/rule_group_agg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ impl<'p> ForwardRuleGroup<'p> {
// contiguous C's keep the source order, but contiguous T's are reversed. Also the overall order
// is reversed, of course.
//
// We do this by using VecDeque, push_back, and make_contiguous in the end.
// We do this by using VecDeque, push_front, and make_contiguous in the end.
#[derive(Debug, Clone)]
pub(crate) struct ReverseRuleGroupAggregator<'p> {
current: ReverseRuleGroup<'p>,
Expand Down Expand Up @@ -264,7 +264,7 @@ impl<'p> ReverseRuleGroupAggregator<'p> {
};
let vec_transform_group = transform_group.into(); // non-allocating conversion
self.groups
.push_back((vec_transform_group, associated_conv_group));
.push_front((vec_transform_group, associated_conv_group));
}
}
}
Expand All @@ -277,7 +277,7 @@ impl<'p> ReverseRuleGroupAggregator<'p> {
if let Some(conv_group) = self.preceding_conversion_group.take() {
// a trailing conversion group in source order is the same as having a conversion
// group as the first in-order group. we can just prepend an empty transform group.
self.groups.push_back((Vec::new(), conv_group));
self.groups.push_front((Vec::new(), conv_group));
}

self.groups.into() // non-allocating conversion
Expand All @@ -289,7 +289,7 @@ impl<'p> ReverseRuleGroupAggregator<'p> {
enum ReverseRuleGroup<'p> {
// because contiguous C's are aggregated in source-order, we can just use a Vec
Conversion(Vec<UniConversionRule<'p>>),
// but contiguous T's are aggregated in reverse-order, so we need to use a VecDeque and push_back
// but contiguous T's are aggregated in reverse-order, so we need to use a VecDeque and push_front
Transform(VecDeque<Cow<'p, parse::SingleId>>),
}

Expand All @@ -306,7 +306,7 @@ impl<'p> ReverseRuleGroup<'p> {

fn new_transform(rule: Cow<'p, parse::SingleId>) -> Self {
let mut group = VecDeque::new();
group.push_back(rule);
group.push_front(rule);
Self::Transform(group)
}

Expand All @@ -319,8 +319,8 @@ impl<'p> ReverseRuleGroup<'p> {
}
(Self::Transform(group), UniRule::Transform(rule)) => {
// we receive rules via `push` in source-order, which is the opposite order we want,
// so we push_back.
group.push_back(rule);
// so we push_front.
group.push_front(rule);
None
}
(Self::Conversion(_), UniRule::Transform(new_rule)) => {
Expand Down

0 comments on commit 9d55038

Please sign in to comment.