Skip to content

Commit

Permalink
Enable ComponentsConfiguration.checkNeedsRemeasure by default
Browse files Browse the repository at this point in the history
Summary: ran the experiment, results were neutral

Reviewed By: muraziz

Differential Revision: D14851297

fbshipit-source-id: 2f0415396fed438a55d584115e99063a2408f2a5
  • Loading branch information
mihaelao authored and facebook-github-bot committed Apr 9, 2019
1 parent c16baf6 commit 6fec385
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4342,7 +4342,7 @@ protected Component onCreateLayout(ComponentContext c) {

@Test
public void testSyncLayoutForUnknownSizeSpec() {
final boolean splitInitRange = ComponentsConfiguration.checkNeedsRemeasure;
final boolean splitInitRange = ComponentsConfiguration.splitLayoutForMeasureAndRangeEstimation;
ComponentsConfiguration.splitLayoutForMeasureAndRangeEstimation = true;
final int NUM_TO_INSERT = 20;

Expand Down Expand Up @@ -4389,7 +4389,7 @@ public void testSyncLayoutForUnknownSizeSpec() {

@Test
public void testNoSyncLayoutForKnownSizeSpec() {
final boolean splitInitRange = ComponentsConfiguration.checkNeedsRemeasure;
final boolean splitInitRange = ComponentsConfiguration.splitLayoutForMeasureAndRangeEstimation;
ComponentsConfiguration.splitLayoutForMeasureAndRangeEstimation = true;
final int NUM_TO_INSERT = 20;

Expand Down Expand Up @@ -4902,8 +4902,6 @@ public void testApplyReadyBatchesInfiniteLoop() {

@Test
public void tesLayoutAsyncInRegisterAsyncInsertWhenRemesureIsNotNeeded() {
final boolean checkNeedsRemeasure = ComponentsConfiguration.checkNeedsRemeasure;
ComponentsConfiguration.checkNeedsRemeasure = true;
final int NUM_TO_INSERT = 5;

final ArrayList<Component> components = new ArrayList<>();
Expand Down Expand Up @@ -4942,14 +4940,10 @@ public void run() {
mHoldersForComponents.get(renderInfos.get(i).getComponent());
assertThat(holder.mLayoutAsyncCalled).isTrue();
}

ComponentsConfiguration.checkNeedsRemeasure = checkNeedsRemeasure;
}

@Test
public void testNoLayoutAsyncInRegisterAsyncInsertWhenRemesureIsNeeded() {
final boolean checkNeedsRemeasure = ComponentsConfiguration.checkNeedsRemeasure;
ComponentsConfiguration.checkNeedsRemeasure = true;
final int NUM_TO_INSERT = 5;

final ArrayList<Component> components = new ArrayList<>();
Expand Down Expand Up @@ -4988,8 +4982,6 @@ public void run() {
mHoldersForComponents.get(renderInfos.get(i).getComponent());
assertThat(holder.mLayoutAsyncCalled).isFalse();
}

ComponentsConfiguration.checkNeedsRemeasure = checkNeedsRemeasure;
}

private RecyclerBinder createRecyclerBinderWithMockAdapter(RecyclerView.Adapter adapterMock) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1980,9 +1980,7 @@ public void measure(

/** @return true if the view is measured and doesn't need remeasuring. */
private synchronized boolean isMeasured() {
return ComponentsConfiguration.checkNeedsRemeasure
? mIsMeasured.get() && !mRequiresRemeasure.get()
: mIsMeasured.get();
return mIsMeasured.get() && !mRequiresRemeasure.get();
}

@VisibleForTesting
Expand Down Expand Up @@ -3015,7 +3013,7 @@ private int getSizeForMeasuring() {

@GuardedBy("this")
private int getActualChildrenWidthSpec(final ComponentTreeHolder treeHolder) {
if (mIsMeasured.get() && !mRequiresRemeasure.get()) {
if (isMeasured()) {
return mLayoutInfo.getChildWidthSpec(
SizeSpec.makeSizeSpec(mMeasuredSize.width, SizeSpec.EXACTLY),
treeHolder.getRenderInfo());
Expand All @@ -3030,7 +3028,7 @@ private int getActualChildrenHeightSpec(final ComponentTreeHolder treeHolder) {
return SizeSpec.UNSPECIFIED;
}

if (mIsMeasured.get() && !mRequiresRemeasure.get()) {
if (isMeasured()) {
return mLayoutInfo.getChildHeightSpec(
SizeSpec.makeSizeSpec(mMeasuredSize.height, SizeSpec.EXACTLY),
treeHolder.getRenderInfo());
Expand Down

0 comments on commit 6fec385

Please sign in to comment.