Closed
Description
I noticed that compiling libcore now takes about 26s instead of the 20s it used to take. perf
revealed that a large amount of time is spent in the bump() method of the lexer. The offending line is:
let next = str::char_range_at(*rdr.src, current_byte_offset);
With rdr
being of type &mut StringReader
and rdr.src
being @~str
. str::char_range_at
expects a &str
as its first argument.
What happens now is that the compiler generates code that copies the whole src
string, which is obviously bad.
The copy is triggered by the rdr
being mutable. Without the mut
, the compiler doesn't generate a copy. A benchmark to demonstrate that behaviour can be found here: https://gist.github.com/dotdash/5546866
@nikomatsakis said he wants to look into this.
Metadata
Metadata
Assignees
Labels
No labels