| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
|
||
| std::function<void()> mValuesFunc; | ||
| mutable bool mValuesSet; | ||
| mutable bool mInSetValues; |
There was a problem hiding this comment.
These two variables can be moved into the mValuesFunc.
Sorry, something went wrong.
There was a problem hiding this comment.
We could do something similar to what we do for memoize:
template<class F>
static std::function<void()> once(F f)
{
bool ran = false;
return [=]() mutable {
if (ran)
return;
ran = true;
f();
};
}
Sorry, something went wrong.
There was a problem hiding this comment.
This was very hacky. I just tried to get rid what I wanted it to do.
These two variables can be moved into the mValuesFunc.
Good point.
We could do something similar to what we do for [memoize]
Will take a look. I know there are patterns for this but I rarely use them so I keep forgetting them.
Sorry, something went wrong.
| const ValueFlow::Value* Token::getContainerSizeValue(const MathLib::bigint val) const | ||
| { | ||
| if (!mImpl->mValues) | ||
| if (values().empty()) |
There was a problem hiding this comment.
values().empty() is redundant here.
Sorry, something went wrong.
There was a problem hiding this comment.
I kept it to avoid the function calls (which obviously won't do much) since some of these might be called loooooots of times. I haven't profiled any of this yet.
Sorry, something went wrong.
There was a problem hiding this comment.
I would not call it "redundant" but "unnecessary". Still needs to be profiled.
Sorry, something went wrong.
| const ValueFlow::Value* Token::getMovedValue() const | ||
| { | ||
| if (!mImpl->mValues) | ||
| if (values().empty()) |
There was a problem hiding this comment.
values().empty() is redundant here.
Sorry, something went wrong.
| const ValueFlow::Value* Token::getMaxValue(bool condition, MathLib::bigint path) const | ||
| { | ||
| if (!mImpl->mValues) | ||
| if (values().empty()) |
There was a problem hiding this comment.
values().empty() is redundant here.
Sorry, something went wrong.
| const ValueFlow::Value* Token::getValue(const MathLib::bigint val) const | ||
| { | ||
| if (!mImpl->mValues) | ||
| if (values().empty()) |
There was a problem hiding this comment.
values().empty() is redundant here.
Sorry, something went wrong.
| return false; | ||
| return mImpl->mValues && | ||
| std::any_of(mImpl->mValues->begin(), mImpl->mValues->end(), [&](const ValueFlow::Value& value) { | ||
| return !values().empty() && |
There was a problem hiding this comment.
values().empty() is redundant here.
Sorry, something went wrong.
| bool Token::hasKnownValue() const | ||
| { | ||
| return mImpl->mValues && std::any_of(mImpl->mValues->begin(), mImpl->mValues->end(), std::mem_fn(&ValueFlow::Value::isKnown)); | ||
| return !values().empty() && std::any_of(values().begin(), values().end(), std::mem_fn(&ValueFlow::Value::isKnown)); |
There was a problem hiding this comment.
values().empty() is redundant here.
Sorry, something went wrong.
| bool Token::hasKnownIntValue() const | ||
| { | ||
| if (!mImpl->mValues) | ||
| if (values().empty()) |
There was a problem hiding this comment.
values().empty() is redundant here.
Sorry, something went wrong.
| const Token *Token::getValueTokenMaxStrLength() const | ||
| { | ||
| if (!mImpl->mValues) | ||
| if (values().empty()) |
There was a problem hiding this comment.
values().empty() is redundant here.
Sorry, something went wrong.
| const Token *Token::getValueTokenMinStrSize(const Settings *settings, MathLib::bigint* path) const | ||
| { | ||
| if (!mImpl->mValues) | ||
| if (values().empty()) |
There was a problem hiding this comment.
values().empty() is redundant here.
Sorry, something went wrong.
| const ValueFlow::Value * Token::getInvalidValue(const Token *ftok, nonneg int argnr, const Settings *settings) const | ||
| { | ||
| if (!mImpl->mValues || !settings) | ||
| if (values().empty() || !settings) |
There was a problem hiding this comment.
values().empty() is redundant here.
Sorry, something went wrong.
| const ValueFlow::Value * Token::getValueGE(const MathLib::bigint val, const Settings *settings) const | ||
| { | ||
| if (!mImpl->mValues) | ||
| if (values().empty()) |
There was a problem hiding this comment.
values().empty() is redundant here.
Sorry, something went wrong.
|
I think its a lot cleaner to use values() instead of mImpl->mValues. However, !mImp->mValues is not the equivalent of !values.empty(). If we use values() then the checks for null can be removed. |
Sorry, something went wrong.
That was my takeaway as well after I "cracked" this and saw only one method needs to access the raw pointers - which is quite nice. I will extract the encapsulation and cleanup parts of this into a separate PR but it still needs some work (see below).
I am aware of that. I already fixed up a few mistakes I made in earlier revisions. But it is still very much WIP... I still have to profile this with valueflow enabled and disabled. Also the lazy execution doesn't save anything at all. There's also some tests failing with the lazy execution. But I guess they just lack the lazy execution hook. Still it is interesting and maybe we should make valueflow more explicit in tests so we know what depends on it. It might also help with determining how to increase the test coverage. But I haven't looked into this at all. |
Sorry, something went wrong.
|
This should "help" (as in executing less code) with tests which use the Tokenizer but do not rely on the ValueFlow. That might also fix the issue I hit in #5299. |
Sorry, something went wrong.
|
I will try to pull out the wrapper function for values so this can finally progress. |
Sorry, something went wrong.
|
I filed https://trac.cppcheck.net/ticket/14243 about this. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
No description provided.