Commit f74b4d5f authored by Giuseppe Ottaviano's avatar Giuseppe Ottaviano Committed by Facebook GitHub Bot

Specialize F14Table default constructor to avoid reserve() instantiation

Summary: F14 class member fields are often in headers, and often the default constructor is implicit. The current implementation unconditionally instantiates `reserve()`, which has non-negligible cost. By specializing the default constructor we can avoid that in the common case.

Reviewed By: philippv, luciang

Differential Revision: D22166465

fbshipit-source-id: d31ebc7f6ab71392d49a6722545f8df9027d034b
parent 19c88ba5
......@@ -105,8 +105,7 @@ class F14BasicMap {
public:
//// PUBLIC - Member functions
F14BasicMap() noexcept(Policy::kDefaultConstructIsNoexcept)
: F14BasicMap(0) {}
F14BasicMap() noexcept(Policy::kDefaultConstructIsNoexcept) : table_{} {}
explicit F14BasicMap(
std::size_t initialCapacity,
......
......@@ -99,8 +99,7 @@ class F14BasicSet {
public:
//// PUBLIC - Member functions
F14BasicSet() noexcept(Policy::kDefaultConstructIsNoexcept)
: F14BasicSet(0) {}
F14BasicSet() noexcept(Policy::kDefaultConstructIsNoexcept) : table_{} {}
explicit F14BasicSet(
std::size_t initialCapacity,
......
......@@ -938,6 +938,11 @@ class F14Table : public Policy {
}
public:
// Equivalent to F14Table(0, ...), but implemented separately to avoid forcing
// a reserve() instantiation in the common case.
F14Table() noexcept(Policy::kDefaultConstructIsNoexcept)
: Policy{Hasher{}, KeyEqual{}, Alloc{}} {}
F14Table(
std::size_t initialCapacity,
Hasher const& hasher,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment