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

Revisit std::map and std::set usage #3980

Closed

Description

@tmpsantos

As flagged by #3179, we use std::set and std::map in places where ordering is not important. In these cases, we should replace with the unordered versions of these containers (faster).

/cc @daniel-j-h

Activity

  1. bleege commented on Sep 12, 2016

    @bleege
    Contributor

    Based on some initial testing @lucaswoj and I have discovered that not all std::set and std::map can be converted to their unordered versions as there still is code in Core GL that relies on their implicit ordering. @jfirebaugh also mentioned that there are places were this is explicitly noted in the source code as well. To make life easier and more transparent, @lucaswoj and I will document these cases as we encounter them in the table below:

    Changed to map only list as @lucaswoj is working with a giant checklist below.

    • mbgl::annotation::annotatation_manager.hpp
    • test/algorithm/covered_by_children.cpp
    • mbgl::algorithm::generate_clip_ids.hpp
    • mbgl::algorithm::generate_clip_ids.cpp
    • mbgl::geometry::glyph_atlas.cpp
    • mbgl::geometry::glyph_atlas.hpp
    • mbgl::text::glyph.hpp
    • mbgl::text::glyph_set.cpp
    • mbgl::text::glyph_set.hpp
    • mbgl::text::glyph_store.hpp
    • test/algorithm/generate_clip_ids.hpp
    • test/algorithm/mock.hpp
    • test/sprite/sprite_store.cpp

    Note

    • While attempting to convert the glyph code to unordered_map it was discovered that it had a dependency on getStencils() which in turn needs to make use of .rend() in generate_clip_ids.cpp. Since this is a larger refactor the decision was made to punt on this part of the refactor for now and take the improvements that we've gotten so far.
  2. lucaswoj commented on Sep 12, 2016

    @lucaswoj
    Contributor

    👉 #6325

  3. jfirebaugh commented on Sep 12, 2016

    @jfirebaugh
    Contributor

    src/clipper is third-party code and as a rule we avoid modifying it. std::setw is a false positive. All the others look like legitimate candidates.

  4. lucaswoj commented on Sep 13, 2016

    @lucaswoj
    Contributor

    Remaining Tasks

  5. added a commit that references this issue on Sep 14, 2016
  6. lucaswoj commented on Sep 15, 2016

    @lucaswoj
    Contributor

    Re-opening. @bleege has merged his PR addressing std::map usage. My PR addressing std::set usage is still pending.

    There are also a few cases that were not resolved in either PR that should:

    • be ticketed out separately
    • keep this Issue open
    • be commented in the source with an explanation of why they are ordered (if not obvious)
  7. bleege commented on Sep 15, 2016

    @bleege
    Contributor

    Re-opening as my fixit PR #6336 closed this automatically.

  8. reopened this on Sep 15, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions