From 069a50bf91dbacfe2e9ade39811be538be3b6bbb Mon Sep 17 00:00:00 2001 From: Yedidya Feldblum Date: Thu, 18 Jul 2024 13:23:14 -0700 Subject: [PATCH] remove outdated branch when StaticMeta creates ThreadEntry Summary: A newly-created `ThreadEntry` is not in the `ThreadEntryList` and cannot have its list-pointer set. No need to check. No perf impact. Just makes the code a touch simpler. Differential Revision: D59329930 fbshipit-source-id: a3e866d6fedfc9feb082c4aba6d18f042a44d36b --- folly/detail/ThreadLocalDetail.h | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/folly/detail/ThreadLocalDetail.h b/folly/detail/ThreadLocalDetail.h index c0be0e69d22..477d69086cb 100644 --- a/folly/detail/ThreadLocalDetail.h +++ b/folly/detail/ThreadLocalDetail.h @@ -679,15 +679,10 @@ struct FOLLY_EXPORT StaticMeta final : StaticMetaBase { if (!threadEntry) { ThreadEntryList* threadEntryList = StaticMeta::getThreadEntryList(); threadEntry = new ThreadEntry(); - // if the ThreadEntry already exists - // but pthread_getspecific returns NULL - // do not add the same entry twice to the list - // since this would create a loop in the list - if (!threadEntry->list) { - threadEntry->list = threadEntryList; - threadEntry->listNext = threadEntryList->head; - threadEntryList->head = threadEntry; - } + + threadEntry->list = threadEntryList; + threadEntry->listNext = threadEntryList->head; + threadEntryList->head = threadEntry; threadEntry->tid() = std::this_thread::get_id(); threadEntry->tid_os = folly::getOSThreadID();