1
Fork 0

Remove unneeded string allocations

This commit is contained in:
Alex Crawford 2018-02-16 14:08:12 -08:00
parent 58a8e0c271
commit c670ae67b6

View file

@ -317,10 +317,10 @@ impl CodeMap {
pub fn mk_substr_filename(&self, sp: Span) -> String { pub fn mk_substr_filename(&self, sp: Span) -> String {
let pos = self.lookup_char_pos(sp.lo()); let pos = self.lookup_char_pos(sp.lo());
(format!("<{}:{}:{}>", format!("<{}:{}:{}>",
pos.file.name, pos.file.name,
pos.line, 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 // If there is a doctest_offset, apply it to the line
@ -462,12 +462,12 @@ impl CodeMap {
let lo = self.lookup_char_pos_adj(sp.lo()); let lo = self.lookup_char_pos_adj(sp.lo());
let hi = self.lookup_char_pos_adj(sp.hi()); let hi = self.lookup_char_pos_adj(sp.hi());
return (format!("{}:{}:{}: {}:{}", format!("{}:{}:{}: {}:{}",
lo.filename, lo.filename,
lo.line, lo.line,
lo.col.to_usize() + 1, lo.col.to_usize() + 1,
hi.line, hi.line,
hi.col.to_usize() + 1)).to_string() hi.col.to_usize() + 1)
} }
pub fn span_to_filename(&self, sp: Span) -> FileName { pub fn span_to_filename(&self, sp: Span) -> FileName {