Skip to content

Commit

Permalink
Rollup merge of #48284 - crawford:string, r=sfackler
Browse files Browse the repository at this point in the history
Remove unneeded string allocations
  • Loading branch information
GuillaumeGomez authored Feb 17, 2018
2 parents 7dd8c09 + c670ae6 commit c4f0011
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/libsyntax/codemap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,10 @@ impl CodeMap {

pub fn mk_substr_filename(&self, sp: Span) -> String {
let pos = self.lookup_char_pos(sp.lo());
(format!("<{}:{}:{}>",
format!("<{}:{}:{}>",
pos.file.name,
pos.line,
pos.col.to_usize() + 1)).to_string()
pos.col.to_usize() + 1)
}

// If there is a doctest_offset, apply it to the line
Expand Down Expand Up @@ -462,12 +462,12 @@ impl CodeMap {

let lo = self.lookup_char_pos_adj(sp.lo());
let hi = self.lookup_char_pos_adj(sp.hi());
return (format!("{}:{}:{}: {}:{}",
format!("{}:{}:{}: {}:{}",
lo.filename,
lo.line,
lo.col.to_usize() + 1,
hi.line,
hi.col.to_usize() + 1)).to_string()
hi.col.to_usize() + 1)
}

pub fn span_to_filename(&self, sp: Span) -> FileName {
Expand Down

0 comments on commit c4f0011

Please sign in to comment.