@@ -1856,6 +1856,10 @@ class F14Table : public Policy {
18561856 }
18571857 }
18581858
1859+ [[FOLLY_ATTR_GNU_COLD]] void eraseBlankCold (ItemIter iter, HashPair hp) {
1860+ eraseBlank (iter, hp);
1861+ }
1862+
18591863 void adjustSizeAndBeginBeforeErase (ItemIter iter) {
18601864 sizeAndChunkShiftAndPackedBegin_.decrementSize ();
18611865 if constexpr (kEnableItemIteration ) {
@@ -1872,15 +1876,11 @@ class F14Table : public Policy {
18721876
18731877 template <typename ... Args>
18741878 void insertAtBlank (ItemIter pos, HashPair hp, Args&&... args) {
1875- catch_exception (
1876- [&] {
1877- auto dst = pos.itemAddr ();
1878- this ->constructValueAtItem (*this , dst, std::forward<Args>(args)...);
1879- },
1880- [this , pos, hp]() {
1881- eraseBlank (pos, hp);
1882- rethrow_current_exception ();
1883- });
1879+ auto rollback =
1880+ folly::makeGuard (std::bind (&F14Table::eraseBlankCold, this , pos, hp));
1881+ auto dst = pos.itemAddr ();
1882+ this ->constructValueAtItem (*this , dst, std::forward<Args>(args)...);
1883+ rollback.dismiss ();
18841884 adjustSizeAndBeginAfterInsert (pos);
18851885 }
18861886
@@ -2104,6 +2104,11 @@ class F14Table : public Policy {
21042104 success = true ;
21052105 }
21062106
2107+ [[FOLLY_ATTR_GNU_COLD]] void buildFromF14TableCatchCold () {
2108+ reset ();
2109+ F14LinkCheck<getF14IntrinsicsMode ()>::check ();
2110+ }
2111+
21072112 template <typename T>
21082113 FOLLY_NOINLINE void buildFromF14Table (T&& src) {
21092114 FOLLY_SAFE_DCHECK (bucket_count () == 0 , " " );
@@ -2124,19 +2129,14 @@ class F14Table : public Policy {
21242129 }
21252130 rehashImpl (0 , 1 , 0 , ccas.first , ccas.second );
21262131
2127- catch_exception (
2128- [&]() {
2129- if (chunkShift () == src.chunkShift ()) {
2130- directBuildFrom (std::forward<T>(src));
2131- } else {
2132- rehashBuildFrom (std::forward<T>(src));
2133- }
2134- },
2135- [this ]() {
2136- reset ();
2137- F14LinkCheck<getF14IntrinsicsMode ()>::check ();
2138- rethrow_current_exception ();
2139- });
2132+ auto rollback = folly::makeGuard (
2133+ std::bind (&F14Table::buildFromF14TableCatchCold, this ));
2134+ if (chunkShift () == src.chunkShift ()) {
2135+ directBuildFrom (std::forward<T>(src));
2136+ } else {
2137+ rehashBuildFrom (std::forward<T>(src));
2138+ }
2139+ rollback.dismiss ();
21402140 }
21412141
21422142 void maybeRehash (std::size_t desiredCapacity, bool attemptExact) {
@@ -2632,10 +2632,7 @@ class F14Table : public Policy {
26322632 auto bc = bucket_count ();
26332633 reset ();
26342634 catch_exception<std::bad_alloc const &>(
2635- [this , bc]() { reserveImpl (bc); },
2636- [](auto &&) {
2637- // ASAN mode only, keep going
2638- });
2635+ [this , bc]() { reserveImpl (bc); }, variadic_noop);
26392636 } else {
26402637 clearImpl<false >();
26412638 }
0 commit comments