]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #60630 - nnethercote:use-Symbol-more, r=petrochenkov
authorbors <bors@rust-lang.org>
Mon, 13 May 2019 00:28:38 +0000 (00:28 +0000)
committerbors <bors@rust-lang.org>
Mon, 13 May 2019 00:28:38 +0000 (00:28 +0000)
Use `Symbol` more

A `Symbol` can be equated with a string (e.g. `&str`). This involves a
TLS lookup to get the chars (and a Mutex lock in a parallel compiler)
and then a char-by-char comparison. This functionality is convenient but
avoids one of the main benefits of `Symbol`s, which is fast equality
comparisons.

This PR removes the `Symbol`/string equality operations, forcing a lot
of existing string occurrences to become `Symbol`s. Fortunately, these
are almost all static strings (many are attribute names) and we can add
static `Symbol`s as necessary, and very little extra interning occurs.
The benefits are (a) a slight speedup (possibly greater in a parallel
compiler), and (b) the code is a lot more principled about `Symbol` use.
The main downside is verbosity, particularly with more `use
syntax::symbol::symbols` items.

r? @Zoxc

1  2 
src/librustc_passes/ast_validation.rs
src/libsyntax/parse/parser.rs

Simple merge
Simple merge