Skip to content

Commit

Permalink
fix(android): expand cache hit range
Browse files Browse the repository at this point in the history
  • Loading branch information
siguangli2018 committed Aug 10, 2023
1 parent 6cbd767 commit fc8228a
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,8 @@ protected Layout createLayout(final float width, final FlexMeasureMode widthMode
if (mSpanned == null || mDirty) {
mSpanned = createSpan(true);
mDirty = false;
} else if (mLayout != null && width >= mLastLayoutWidth && width <= (mLastLayoutWidth + 1)) {
} else if (mLayout != null && width >= (mLastLayoutWidth - 1)
&& width <= (mLastLayoutWidth + 1)) {
// If the property of text node no change, and the current layout width is equal
// to the last measurement result, no need to create layout again.
return mLayout;
Expand All @@ -468,7 +469,7 @@ protected Layout createLayout(final float width, final FlexMeasureMode widthMode
} else {
float desiredWidth = Layout.getDesiredWidth(mSpanned, textPaint);
if (!unconstrainedWidth && (widthMode == FlexMeasureMode.EXACTLY
|| desiredWidth > width)) {
|| desiredWidth > width)) {
desiredWidth = width;
}
layout = buildStaticLayout(mSpanned, textPaint, (int) Math.ceil(desiredWidth));
Expand Down

0 comments on commit fc8228a

Please sign in to comment.