Simplify Alignment::pretty#17
Open
TianyiShi2001 wants to merge 2 commits into
Open
Conversation
tedil
requested changes
Oct 23, 2020
Comment on lines
+202
to
+211
| // SAFETY: validity checked before creating an Alignment | ||
| unsafe { | ||
| x_pretty.push_str(std::str::from_utf8_unchecked(&x[..self.xstart])); | ||
| } | ||
| for k in y.iter().take(self.ystart) { | ||
| y_pretty.push_str(&format!("{}", String::from_utf8_lossy(&[*k]))); | ||
| inb_pretty.push(' '); | ||
| x_pretty.push(' ') | ||
| y_pretty.push_str(&" ".repeat(self.xstart)); | ||
| unsafe { | ||
| y_pretty.push_str(std::str::from_utf8_unchecked(&y[..self.ystart])); | ||
| } | ||
| x_pretty.push_str(&" ".repeat(self.ystart)); | ||
| inb_pretty.push_str(&" ".repeat(self.xstart + self.ystart)); |
Member
There was a problem hiding this comment.
I'm not too fond of unnecessary unsafes, and I doubt performance is crucial for pretty printing alignments (disregarding the fact that this might not even be faster).
However, since TextSlice is just an alias for &'a [u8] and u8 as char though confusing, usually works as expected, x_pretty.push_str(...) may be replaced by &x[..self.xstart].for_each(|x| x_pretty.push(x as char)) or so.
Member
|
Just a quick ping to see, if there are any plans on following up on this? If not, we might close this whenever we come back to sifting through the pull requests over here. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This should be faster and cleaner.