+#ifdef FOLLY_TLD_USE_FOLLY_TLS
+ // Eliminate as many branches as possible:
+ // One branch on capacityCache, vs. three:
+ // 1) instance() static initializer
+ // 2) getThreadEntry null check
+ // 3) elementsCapacity size check.
+ // 3 will never be true if 1 or 2 are false.
+ FOLLY_ALWAYS_INLINE static ElementWrapper& get(EntryID* ent) {
+ uint32_t id = ent->getOrInvalid();
+ if (UNLIKELY(capacityCache_ <= id)) {
+ return getSlow(ent);
+ } else {
+ return threadEntryCache_->elements[id];
+ }
+ }
+
+ static ElementWrapper& getSlow(EntryID* ent) {
+ ElementWrapper& res = instance().getElement(ent);
+ // Cache new capacity
+ capacityCache_ = getThreadEntry()->elementsCapacity;
+ return res;
+ }
+#else
+ static ElementWrapper& get(EntryID* ent) {
+ return instance().getElement(ent);
+ }
+#endif
+
+ ElementWrapper& getElement(EntryID* ent) {