diff --git a/src/Effect.cpp b/src/Effect.cpp index bccac5480..eb284e42c 100644 --- a/src/Effect.cpp +++ b/src/Effect.cpp @@ -298,20 +298,16 @@ Effect::add_external_effect(const Effect &e, std::vector call_chai } /* - * TODO: tried doing this with `find', but I couldn't get all the `const's - * right. Gave up; wrote it by hand! + * + * */ bool Effect::is_read(const Variable *v) const { - vector::size_type len = read_vars.size(); - vector::size_type i; - - for (i = 0; i < len; ++i) { - if (read_vars[i] == v) { - return true; - } + if (std::find(read_vars.begin(), read_vars.end(), v) != read_vars.end()) { + return true; } + // if we read a struct, presumingly all the fields are read too // however we can not say the same thing for unions: reading a particular // unions field can cause unspecified behaviors, while reading the whole @@ -319,6 +315,7 @@ Effect::is_read(const Variable *v) const if (v->field_var_of && v->field_var_of->type->eType == eStruct) { return is_read(v->field_var_of); } + return false; }