Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a SmallMap to base for small map lookups.
This map has a static array that it will check brute-force before overflowing into a normal map. For cases where simple key-value lookup is needed where there are not expected to be many elements, this will be faster. This adds ManualConstructor which is required for this. This code is from internal util/gtl/small_map.h. I made the following changes: Renamed small_map to SmallMap. Added everything to the base namespace. Added the helper templates at the top to a sub namespace "internal" I renamed small_map_default_init to SmallMapDefaultInit since it's a class and that's how we name clases. However, I didn't rename has_key_equal and select_key_equal since those work with something called key_equal on the base container. I went back and forth on this, I'm happy to change. Renamed the non-STL-like functions to CamelCase. The only case was "using_full_map" -> UsingFullMap Removed unit test for the size of a Small Map (I don't think we care). Added note about preferring hash_map for key equality checking. Redid manual_constructor to use aligned_memory instead of manually doing everything itself. This removed a bunch of preprocessor goop and manual alignment. I also removed the 9-12 argument constructor versions of Init, which seemed excessive. Removed InsertIfNotPresent unit test (we don't have an InsertIfNotPresent map helper function). Added std:: on various things like pairs and make_pair and max. Made SmallMap::size() and count() and erase() return size_t insted of int to keep compat for unsigned-vs-signed for STL. Added "u" after numbers in EXPECT_EQs to avoid signed/unsigned warnings. BUG= Review URL: https://codereview.chromium.org/11366050 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@167001 0039d316-1c4b-4281-b951-d872f2087c98
- Loading branch information