diff --git a/fluent-bundle/src/resolver/pattern.rs b/fluent-bundle/src/resolver/pattern.rs index 48f79616..dc331739 100644 --- a/fluent-bundle/src/resolver/pattern.rs +++ b/fluent-bundle/src/resolver/pattern.rs @@ -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 } => { diff --git a/fluent-bundle/src/resolver/scope.rs b/fluent-bundle/src/resolver/scope.rs index f682a576..8d2e24be 100644 --- a/fluent-bundle/src/resolver/scope.rs +++ b/fluent-bundle/src/resolver/scope.rs @@ -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( &mut self, w: &mut W,