Skip to content

Commit

Permalink
Remove ThreadStorage class in favour of thread_local
Browse files Browse the repository at this point in the history
Summary:
#changelog: [internal]

When I built ThreadStorage I didn't know about existence of `thread_local` keyword. Because it achieves the same goal, using built in c++ features is preferred over building our own.

Reviewed By: JoshuaGross, shergin

Differential Revision: D24380680

fbshipit-source-id: e961fc34c6d3f085fc9b918b20bb4827de0d5624
  • Loading branch information
sammy-SC authored and facebook-github-bot committed Oct 19, 2020
1 parent 500bdf7 commit 1ca5ccc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include <react/renderer/core/LayoutContext.h>
#include <react/renderer/debug/DebugStringConvertibleItem.h>
#include <react/renderer/debug/SystraceSection.h>
#include <react/utils/ThreadStorage.h>
#include <yoga/Yoga.h>
#include <algorithm>
#include <limits>
Expand All @@ -21,6 +20,8 @@
namespace facebook {
namespace react {

thread_local LayoutContext threadLocalLayoutContext;

static void applyLayoutConstraints(
YGStyle &yogaStyle,
LayoutConstraints const &layoutConstraints) {
Expand Down Expand Up @@ -332,7 +333,7 @@ void YogaLayoutableShadowNode::layoutTree(

applyLayoutConstraints(yogaNode_.getStyle(), layoutConstraints);

ThreadStorage<LayoutContext>::getInstance().set(layoutContext);
threadLocalLayoutContext = layoutContext;

if (layoutContext.swapLeftAndRightInRTL) {
swapLeftAndRightInTree(*this);
Expand Down Expand Up @@ -492,10 +493,8 @@ YGSize YogaLayoutableShadowNode::yogaNodeMeasureCallbackConnector(
break;
}

auto layoutContext = ThreadStorage<LayoutContext>::getInstance().get();

auto size = shadowNodeRawPtr->measureContent(
layoutContext.value_or(LayoutContext{}), {minimumSize, maximumSize});
threadLocalLayoutContext, {minimumSize, maximumSize});

return YGSize{yogaFloatFromFloat(size.width),
yogaFloatFromFloat(size.height)};
Expand Down
57 changes: 0 additions & 57 deletions ReactCommon/react/utils/ThreadStorage.h

This file was deleted.

0 comments on commit 1ca5ccc

Please sign in to comment.