summaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorajreynol <reynolds@larapc05.epfl.ch>2014-05-02 10:57:51 +0200
committerajreynol <reynolds@larapc05.epfl.ch>2014-05-02 10:57:51 +0200
commit7d3f8788309cfb241df60e6924861dd9884e1a7b (patch)
tree5b3172e2280502eabd0db2fc5449e96d30604262 /src/util
parentf040f95e28f2f9fda6c88243f550ff63b3faac22 (diff)
More minor optimizations for datatypes.
Diffstat (limited to 'src/util')
-rw-r--r--src/util/datatype.cpp15
-rw-r--r--src/util/datatype.h3
2 files changed, 12 insertions, 6 deletions
diff --git a/src/util/datatype.cpp b/src/util/datatype.cpp
index 4d45d9148..f0ddc2cf6 100644
--- a/src/util/datatype.cpp
+++ b/src/util/datatype.cpp
@@ -124,6 +124,14 @@ void Datatype::resolve(ExprManager* em,
Node::fromExpr((*i).d_tester).setAttribute(DatatypeIndexAttr(), index++);
}
d_self = self;
+
+ d_involvesExt = false;
+ for(const_iterator i = begin(); i != end(); ++i) {
+ if( (*i).involvesExternalType() ){
+ d_involvesExt = true;
+ break;
+ }
+ }
}
void Datatype::addConstructor(const DatatypeConstructor& c) {
@@ -404,12 +412,7 @@ Expr Datatype::getConstructor(std::string name) const {
}
bool Datatype::involvesExternalType() const{
- for(const_iterator i = begin(); i != end(); ++i) {
- if( (*i).involvesExternalType() ){
- return true;
- }
- }
- return false;
+ return d_involvesExt;
}
void DatatypeConstructor::resolve(ExprManager* em, DatatypeType self,
diff --git a/src/util/datatype.h b/src/util/datatype.h
index a8f3b404a..befb3428d 100644
--- a/src/util/datatype.h
+++ b/src/util/datatype.h
@@ -452,6 +452,7 @@ private:
std::vector<DatatypeConstructor> d_constructors;
bool d_resolved;
Type d_self;
+ bool d_involvesExt;
// "mutable" because computing the cardinality can be expensive,
// and so it's computed just once, on demand---this is the cache
@@ -673,6 +674,7 @@ inline Datatype::Datatype(std::string name, bool isCo) :
d_constructors(),
d_resolved(false),
d_self(),
+ d_involvesExt(false),
d_card(CardinalityUnknown()) {
}
@@ -683,6 +685,7 @@ inline Datatype::Datatype(std::string name, const std::vector<Type>& params, boo
d_constructors(),
d_resolved(false),
d_self(),
+ d_involvesExt(false),
d_card(CardinalityUnknown()) {
}
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback