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

[generator] Fixed foot/bicycle tag from Relation. #8034

Merged
merged 3 commits into from
May 2, 2024
Merged

[generator] Fixed foot/bicycle tag from Relation. #8034

merged 3 commits into from
May 2, 2024

Conversation

vng
Copy link
Member

@vng vng commented Apr 29, 2024

@vng vng requested review from biodranik and pastk April 29, 2024 15:15
}

bool OsmElement::HasTag(std::string const & key) const
bool OsmElement::HasTag(std::string_view const & key) const
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
bool OsmElement::HasTag(std::string_view const & key) const
bool OsmElement::HasTag(std::string_view key) const

Copy link
Member Author

Choose a reason for hiding this comment

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

Like we always do m2::PointD const &, I don't see a reason to bother/change here.
Anyway, both variants are ok.

Copy link
Member

Choose a reason for hiding this comment

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

There is a difference, of course. The reference version reads memory, the value version reads registers, and two fewer assembler lines: https://godbolt.org/z/351fvnhc4

The same for PointD, memory reads are replaced with register operations https://godbolt.org/z/KT9KPjzcq . So if we migrate to pass-by-value, 64 bit devices will definitely win. 32 bit ones at least work at the same speed:

выява

{
return base::AnyOf(m_tags, [&](auto const & t) { return t.m_key == key; });
}

bool OsmElement::HasTag(std::string const & key, std::string const & value) const
bool OsmElement::HasTag(std::string_view const & key, std::string_view const & value) const
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
bool OsmElement::HasTag(std::string_view const & key, std::string_view const & value) const
bool OsmElement::HasTag(std::string_view key, std::string_view value) const

Copy link
Member

Choose a reason for hiding this comment

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

At least it is important for consistency. We don't want to have double standards, right? )

Comment on lines +107 to +108
bool HasTag(std::string_view const & key) const;
bool HasTag(std::string_view const & key, std::string_view const & value) const;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
bool HasTag(std::string_view const & key) const;
bool HasTag(std::string_view const & key, std::string_view const & value) const;
bool HasTag(std::string_view key) const;
bool HasTag(std::string_view key, std::string_view value) const;

@@ -23,18 +23,23 @@ bool RelationTagsBase::IsSkipRelation(std::string_view type)
return type == "multipolygon" || type == "bridge";
}

bool RelationTagsBase::IsKeyTagExists(std::string const & key) const
bool RelationTagsBase::IsKeyTagExists(std::string_view const & key) const
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
bool RelationTagsBase::IsKeyTagExists(std::string_view const & key) const
bool RelationTagsBase::IsKeyTagExists(std::string_view key) const

@@ -142,9 +147,9 @@ void RelationTagsWay::Process(RelationElement const & e)
if (isHighway)
{
if (route == "bicycle")
Base::AddCustomTag({"bicycle", "yes"});
Base::AddTagIfNotExist("bicycle", "yes");
Copy link
Member

Choose a reason for hiding this comment

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

This code will always be called after the correct bicycle tag has been already added, right?

@@ -39,8 +39,14 @@ class RelationTagsBase

protected:
static bool IsSkipRelation(std::string_view type);
bool IsKeyTagExists(std::string const & key) const;
void AddCustomTag(std::pair<std::string, std::string> const & p);
bool IsKeyTagExists(std::string_view const & key) const;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
bool IsKeyTagExists(std::string_view const & key) const;
bool IsKeyTagExists(std::string_view key) const;

void AddCustomTag(std::pair<std::string, std::string> const & p);
bool IsKeyTagExists(std::string_view const & key) const;
void AddCustomTag(std::string_view key, std::string_view value);
void AddCustomTag(std::pair<std::string, std::string> const & p)
Copy link
Member

Choose a reason for hiding this comment

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

Is this still needed/used?

SKIP_KEY_BY_PREFIX("note");
SKIP_KEY_BY_PREFIX("fixme");
SKIP_KEY_BY_PREFIX("iemv");
std::string_view kUselessKeys[] = {
Copy link
Member

Choose a reason for hiding this comment

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

constexpr or const?

}

bool OsmElement::HasTag(std::string const & key) const
bool OsmElement::HasTag(std::string_view const & key) const
Copy link
Member

Choose a reason for hiding this comment

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

There is a difference, of course. The reference version reads memory, the value version reads registers, and two fewer assembler lines: https://godbolt.org/z/351fvnhc4

The same for PointD, memory reads are replaced with register operations https://godbolt.org/z/KT9KPjzcq . So if we migrate to pass-by-value, 64 bit devices will definitely win. 32 bit ones at least work at the same speed:

выява

{
return base::AnyOf(m_tags, [&](auto const & t) { return t.m_key == key; });
}

bool OsmElement::HasTag(std::string const & key, std::string const & value) const
bool OsmElement::HasTag(std::string_view const & key, std::string_view const & value) const
Copy link
Member

Choose a reason for hiding this comment

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

At least it is important for consistency. We don't want to have double standards, right? )

vng added 3 commits May 2, 2024 09:01
… yet.

Signed-off-by: Viktor Govako <viktor.govako@gmail.com>
Signed-off-by: Viktor Govako <viktor.govako@gmail.com>
Signed-off-by: Viktor Govako <viktor.govako@gmail.com>
@vng vng merged commit 3200522 into master May 2, 2024
10 checks passed
@vng vng deleted the vng-fix branch May 2, 2024 12:45
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.

None yet

3 participants