Simplify AndroidTextInputProps::getDiffProps (#57151)#57151
Open
sammy-SC wants to merge 2 commits into
Open
Conversation
Summary: `BaseTextProps::appendTextAttributesProps` builds a `folly::dynamic` diff of ~29 text attributes through a long flat sequence of per-attribute `if (changed) result[key] = ...` blocks, many with an embedded `has_value() ? convert(...) : nullptr` ternary. That gave the function a cyclomatic complexity (CCN) of 47, well into the "complex, hard to test" range. This is a pure, behavior-preserving refactor. The four recurring compare-and-assign shapes — plain `!=`, `floatEquality`, optional-with-converter, and color dereference — are pulled into small file-local `static` helpers, and the function body becomes a flat list of helper calls in the exact same order, with the exact same keys, conversions, and values. The serialized output (including `folly::dynamic` insertion order) is identical. Only the `.cpp` is touched; there are no public header or API changes. Changelog: [Internal] Differential Revision: D108027815
Summary: `AndroidTextInputProps::getDiffProps` computes a `folly::dynamic` prop diff through ~57 sequential per-prop `if (field != oldProps->field) result[key] = ...` blocks (plus a nested `has_value()` branch for `textAlignVertical` and an optional ternary for `acceptDragAndDropTypes`), giving the function a cyclomatic complexity (CCN) of 63 — past the landing threshold. This is a pure, behavior-preserving refactor. The recurring compare-and-assign shapes — plain `!=`, color dereference, `floatEquality`, direct `toString`/`toDynamic` conversion, and optional-with-converter — are pulled into small file-local `static` helpers, and the body becomes a flat list of helper calls in the exact same order, with the same keys, comparisons (`!=` vs `floatEquality`), conversions, and values. The serialized output (including `folly::dynamic` insertion order, so the duplicate `numberOfLines`/`includeFontPadding` keys still resolve identically) is unchanged. Only the `.cpp` is touched; there are no public header or API changes. Changelog: [Internal] Differential Revision: D108027818
73ea335 to
5663ef6
Compare
AndroidTextInputProps::getDiffPropsAndroidTextInputProps::getDiffProps (#57151)
|
@sammy-SC has exported this pull request. If you are a Meta employee, you can view the originating Diff in D108027818. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
AndroidTextInputProps::getDiffPropscomputes afolly::dynamicprop diff through ~57 sequential per-propif (field != oldProps->field) result[key] = ...blocks (plus a nestedhas_value()branch fortextAlignVerticaland an optional ternary foracceptDragAndDropTypes), giving the function a cyclomatic complexity (CCN) of 63 — past the landing threshold.This is a pure, behavior-preserving refactor. The recurring compare-and-assign shapes — plain
!=, color dereference,floatEquality, directtoString/toDynamicconversion, and optional-with-converter — are pulled into small file-localstatichelpers, and the body becomes a flat list of helper calls in the exact same order, with the same keys, comparisons (!=vsfloatEquality), conversions, and values. The serialized output (includingfolly::dynamicinsertion order, so the duplicatenumberOfLines/includeFontPaddingkeys still resolve identically) is unchanged. Only the.cppis touched; there are no public header or API changes.Changelog: [Internal]
Differential Revision: D108027818