Skip to content

Commit

Permalink
Rollup merge of rust-lang#4830 - lzutao:str-repeat, r=flip1995
Browse files Browse the repository at this point in the history
use more efficient code to generate repeated string

see https://rust.godbolt.org/z/z9vrFP for comparison

changelog: none
  • Loading branch information
flip1995 authored Nov 23, 2019
2 parents f5aba9e + d229d91 commit 030ae86
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion clippy_lints/src/strings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for StringLitAsBytes {
if let LitKind::Str(ref lit_content, style) = lit.node {
let callsite = snippet(cx, args[0].span.source_callsite(), r#""foo""#);
let expanded = if let StrStyle::Raw(n) = style {
let term = (0..n).map(|_| '#').collect::<String>();
let term = "#".repeat(usize::from(n));
format!("r{0}\"{1}\"{0}", term, lit_content.as_str())
} else {
format!("\"{}\"", lit_content.as_str())
Expand Down

0 comments on commit 030ae86

Please sign in to comment.