Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use cstring() instead of the empty cstring #269

Merged
merged 2 commits into from
Feb 1, 2017

Conversation

mihaibudiu
Copy link
Contributor

Changes suggested by @ChrisDodd

@@ -76,7 +76,7 @@ class KeyNameGenerator : public Inspector {

cstring getName(const IR::Expression* expression) {
if (name.find(expression) == name.end())
return "";
return cstring();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check is unneded -- ::get will return cstring() if the expression is not in the map.

@@ -36,15 +36,15 @@ class KeyNameGenerator : public Inspector {

void postorder(const IR::Member* expression) override {
cstring n = getName(expression->expr);
if (n.isNullOrEmpty())
if (!n)
return;
name.emplace(expression, n + "." + expression->member);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be written more concisely as

if (cstring n = ::get(name, expression->expr))
    name.emplace(expression, n + "." + expressions->member);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants