rust/src/libsyntax
kennytm 445718084f
Rollup merge of #53521 - alexcrichton:optimize-lit-token, r=michaelwoerister
syntax: Optimize some literal parsing

Currently in the `wasm-bindgen` project we have a very very large crate that's
procedurally generated, `web-sys`. To generate this crate we parse all of a
browser's WebIDL and we then generate bindings for all of the APIs contained
within.

The resulting Rust file is 18MB large (wow!) and currently takes a very long
time to compile in debug mode. On the nightly compiler a *debug* build takes 90s
for the crate to finish. I was curious what was taking so long and upon
investigating a *massive* portion of the time was spent in the `lit_token`
method of the compiler, primarily formatting strings via `format!`.

Upon some more investigation it looks like the `byte_str_lit` was allocating an
error message once per byte, causing a very large number of allocations to
happen for large literals, of which wasm-bindgen generates quite a few (some are
MB large).

This commit fixes the issue by lazily allocating the error message, only doing
so if the error message is actually needed (which should be never). As a result,
the debug mode compilation time for our `web-sys` crate decreased from 90s to
20s, a very nice improvement! (although we've still got some work to do).
2018-08-21 17:51:52 +08:00
..
attr mv (mod) codemap source_map 2018-08-19 23:01:00 +02:00
diagnostics mv codemap() source_map() 2018-08-19 23:01:01 +02:00
ext Rollup merge of #53496 - matthiaskrgr:codespell_08_2018, r=varkor 2018-08-21 17:51:49 +08:00
parse Rollup merge of #53521 - alexcrichton:optimize-lit-token, r=michaelwoerister 2018-08-21 17:51:52 +08:00
print mv (mod) codemap source_map 2018-08-19 23:01:00 +02:00
util mv codemap() source_map() 2018-08-19 23:01:01 +02:00
ast.rs mv (mod) codemap source_map 2018-08-19 23:01:00 +02:00
build.rs rustc: Add some build scripts for librustc crates 2017-07-22 22:04:13 -07:00
Cargo.toml rustc_target: move in syntax::abi and flip dependency. 2018-04-26 17:49:16 +03:00
config.rs mv (mod) codemap source_map 2018-08-19 23:01:00 +02:00
diagnostic_list.rs Fix diagnostic_list error 2018-08-05 22:26:06 +01:00
early_buffered_lints.rs make it a migration lint 2018-07-23 21:55:51 -05:00
entry.rs Cleanup InternedString. 2016-11-21 09:00:56 +00:00
feature_gate.rs Rollup merge of #53370 - jkozlowski:stabilize-macro_vis_matcher, r=cramertj 2018-08-21 17:51:38 +08:00
fold.rs mv (mod) codemap source_map 2018-08-19 23:01:00 +02:00
json.rs mv (mod) codemap source_map 2018-08-19 23:01:00 +02:00
lib.rs mv (mod) codemap source_map 2018-08-19 23:01:00 +02:00
ptr.rs Remove most of PartialEq impls from AST and HIR structures 2018-07-14 14:56:57 +03:00
README.md Replace many of the last references to readmes 2018-03-16 12:43:22 -05:00
show_span.rs use field init shorthand EVERYWHERE 2017-08-15 15:29:17 -07:00
source_map.rs fix tidy errors 2018-08-19 23:01:01 +02:00
std_inject.rs mv codemap source_map 2018-08-19 23:01:01 +02:00
str.rs Inline char_at() and record_width. 2018-05-13 17:16:02 +10:00
test.rs mv codemap source_map 2018-08-19 23:01:01 +02:00
test_snippet.rs mv (mod) codemap source_map 2018-08-19 23:01:00 +02:00
tokenstream.rs TokenStream::extend 2018-08-12 22:45:32 -07:00
visit.rs Implement existential types 2018-07-18 10:53:08 +02:00

The syntax crate contains those things concerned purely with syntax that is, the AST ("abstract syntax tree"), parser, pretty-printer, lexer, macro expander, and utilities for traversing ASTs.

For more information about how these things work in rustc, see the rustc guide: