Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

[core] Skip duplicated IDs when querying point annotations - #6655

Merged
brunoabinader merged 1 commit into
masterfrom
filter-query-point-annotations
Oct 12, 2016
Merged

brunoabinader merged 1 commit into
masterfrom
filter-query-point-annotations

Conversation

@brunoabinader

Copy link
Copy Markdown
Contributor

Extracted out of #3563.

/cc @ivovandongen

@brunoabinader brunoabinader added bug Core The cross-platform C++ core, aka mbgl labels Oct 11, 2016
@mention-bot

Copy link
Copy Markdown

@brunoabinader, thanks for your PR! By analyzing the history of the files in this pull request, we identified @1ec5, @jfirebaugh and @kkaefer to be potential reviewers.

Comment thread src/mbgl/map/map.cpp Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is an O(n²) algorithm. Better use a set to do deduplication.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Now using AnnotationIDs as a typedef for std::set<AnnotationID>. This involves updating platform code that uses Map::queryPointAnnotations().

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Now using AnnotationIDs as a typedef for std::set.

It turned out that platform code logic depended on particularities of std::vector e.g. ability to reassign member values via std::remove_if that would end up adding more code complexity by converting it to an approach in which std::set is compatible with.

Thus, I'm keeping AnnotationIDs as a std::vector. I'm using std::set internally when issuing the query and later moving those values to a std::vector, preserving linear complexity.

@brunoabinader
brunoabinader force-pushed the filter-query-point-annotations branch 6 times, most recently from 325b48f to 862c198 Compare October 12, 2016 04:39
@brunoabinader
brunoabinader merged commit 436a22e into master Oct 12, 2016
@brunoabinader
brunoabinader deleted the filter-query-point-annotations branch October 12, 2016 15:59
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

bug Core The cross-platform C++ core, aka mbgl

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants