Skip to content

Commit

Permalink
improve documentation in resolver code
Browse files Browse the repository at this point in the history
  • Loading branch information
JasperDeSutter committed Jan 28, 2023
1 parent a1229ca commit 7ad6779
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fluent-bundle/src/resolver/pattern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ impl<'bundle> ResolveValue<'bundle> for ast::Pattern<&'bundle str> {
{
let len = self.elements.len();

// more than 1 element means concatenation, which is more efficient to write to a String
// 1 element often means just a message reference that can be passed back as a Cow::Borrowed
// If there is only 1 element, then it is more efficient to attempt to resolve as a message
// reference that can be passed back as a Cow::Borrowed rather than writing a new String.
if len == 1 {
match &self.elements[0] {
&ast::PatternElement::TextElement { value } => {
Expand Down
4 changes: 4 additions & 0 deletions fluent-bundle/src/resolver/scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ impl<'bundle, 'ast, 'args, 'errors, R, M> Scope<'bundle, 'ast, 'args, 'errors, R
}
}

/// Cyclic pattern reference detection used in expression resolvers.
///
/// Writes an error as soon as an identical pattern is encountered more than once,
/// which would lead to an infinite loop.
pub fn track<W>(
&mut self,
w: &mut W,
Expand Down

0 comments on commit 7ad6779

Please sign in to comment.