summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Fitzgerald <fitzgen@gmail.com>2017-08-14 11:52:05 -0700
committerNick Fitzgerald <fitzgen@gmail.com>2017-08-14 11:52:05 -0700
commit949ab272101a0c10da3d6d85458597318eb8d15b (patch)
treef2a9aee1170ed6067fdd450a95bb9310a0ebbcad
parent5ca05690c17e318d52f8d2e82aeef5d0feff35b3 (diff)
Only run analyses when we are going to use their results
Currently, there are various analyses related to deriving various traits that we unconditionally run. However, if we aren't going to derive those traits in codegen, then computing whether or not we can derive the traits is wasteful.
-rw-r--r--src/ir/context.rs12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/ir/context.rs b/src/ir/context.rs
index a2493aee..d9bbad92 100644
--- a/src/ir/context.rs
+++ b/src/ir/context.rs
@@ -1790,7 +1790,9 @@ impl<'ctx> BindgenContext<'ctx> {
/// Compute whether we can derive debug.
fn compute_cannot_derive_debug(&mut self) {
assert!(self.cannot_derive_debug.is_none());
- self.cannot_derive_debug = Some(analyze::<CannotDeriveDebug>(self));
+ if self.options.derive_debug {
+ self.cannot_derive_debug = Some(analyze::<CannotDeriveDebug>(self));
+ }
}
/// Look up whether the item with `id` can
@@ -1807,7 +1809,9 @@ impl<'ctx> BindgenContext<'ctx> {
/// Compute whether we can derive default.
fn compute_cannot_derive_default(&mut self) {
assert!(self.cannot_derive_default.is_none());
- self.cannot_derive_default = Some(analyze::<CannotDeriveDefault>(self));
+ if self.options.derive_default {
+ self.cannot_derive_default = Some(analyze::<CannotDeriveDefault>(self));
+ }
}
/// Look up whether the item with `id` can
@@ -1830,7 +1834,9 @@ impl<'ctx> BindgenContext<'ctx> {
/// Compute whether we can derive hash.
fn compute_cannot_derive_hash(&mut self) {
assert!(self.cannot_derive_hash.is_none());
- self.cannot_derive_hash = Some(analyze::<CannotDeriveHash>(self));
+ if self.options.derive_hash {
+ self.cannot_derive_hash = Some(analyze::<CannotDeriveHash>(self));
+ }
}
/// Look up whether the item with `id` can