diff options
| author | Oliver Scherer <github35764891676564198441@oli-obk.de> | 2019-02-07 14:19:06 +0100 |
|---|---|---|
| committer | Oliver Scherer <github35764891676564198441@oli-obk.de> | 2019-02-11 15:08:17 +0100 |
| commit | b681433b9d40ce1d851d22bedb7ccb483bedda06 (patch) | |
| tree | 58553f5e5d930db8c101e2b698fa43ed38a09ee0 /src/libsyntax_pos | |
| parent | 1dba7cb20224b5bb3a22641b2f4f2f73e5157dee (diff) | |
| download | rust-b681433b9d40ce1d851d22bedb7ccb483bedda06.tar.gz rust-b681433b9d40ce1d851d22bedb7ccb483bedda06.zip | |
Use `Rc<[Symbol]>` instead of `Vec<Symbol>` to reduce # of allocs
Diffstat (limited to 'src/libsyntax_pos')
| -rw-r--r-- | src/libsyntax_pos/hygiene.rs | 3 | ||||
| -rw-r--r-- | src/libsyntax_pos/lib.rs | 5 |
2 files changed, 5 insertions, 3 deletions
diff --git a/src/libsyntax_pos/hygiene.rs b/src/libsyntax_pos/hygiene.rs index f9394826c9b..fb9b4c9d70e 100644 --- a/src/libsyntax_pos/hygiene.rs +++ b/src/libsyntax_pos/hygiene.rs @@ -13,6 +13,7 @@ use crate::symbol::{keywords, Symbol}; use serialize::{Encodable, Decodable, Encoder, Decoder}; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use std::{fmt, mem}; +use std::rc::Rc; /// A SyntaxContext represents a chain of macro expansions (represented by marks). #[derive(Clone, Copy, PartialEq, Eq, Default, PartialOrd, Ord, Hash)] @@ -553,7 +554,7 @@ pub struct ExpnInfo { /// List of #[unstable]/feature-gated features that the macro is allowed to use /// internally without forcing the whole crate to opt-in /// to them. - pub allow_internal_unstable: Vec<Symbol>, + pub allow_internal_unstable: Option<Rc<[Symbol]>>, /// Whether the macro is allowed to use `unsafe` internally /// even if the user crate has `#![forbid(unsafe_code)]`. pub allow_internal_unsafe: bool, diff --git a/src/libsyntax_pos/lib.rs b/src/libsyntax_pos/lib.rs index 87c4d02fa4f..f0dc1b00fd9 100644 --- a/src/libsyntax_pos/lib.rs +++ b/src/libsyntax_pos/lib.rs @@ -389,8 +389,9 @@ impl Span { match self.ctxt().outer().expn_info() { Some(info) => info .allow_internal_unstable - .iter() - .any(|&f| f == feature || f == "allow_internal_unstable_backcompat_hack"), + .map_or(false, |features| features.iter().any(|&f| + f == feature || f == "allow_internal_unstable_backcompat_hack" + )), None => false, } } |
