You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A little suggestion. It seems like first check and second check do the same check implicitly.
Is there a case where the first check is false and the second true ? What do you think ?
pubfnis_valid(&self) -> bool{self.lines.is_char_boundary(self.insertion_point())// first check
&& (self.lines.grapheme_indices(true).any(|(i, _)| i == self.insertion_point())
|| self.insertion_point() == self.lines.len())// second check
&& std::str::from_utf8(self.lines.as_bytes()).is_ok()}
The text was updated successfully, but these errors were encountered:
You are correct that if the second test (grapheme cluster boundary) is true the first one (UTF-8 char boundary) will always be true.
The first check is local and only needs to check the byte at the index (or length), while the follow-on second check requires us to traverse the string. Without benchmarking with real data (that is most likely valid), there could be a questionable argument about short-circuiting saving us the work for the second check. Given that we expect valid data anyways, we could probably elide the first check.
A little suggestion. It seems like first check and second check do the same check implicitly.
Is there a case where the first check is false and the second true ? What do you think ?
The text was updated successfully, but these errors were encountered: