Skip to content

Commit d177839

Browse files
christophpurrermeta-codesync[bot]
authored andcommitted
Fix bugprone-use-after-move in JSINativeModules.cpp and bugprone-optional-value-conversion in TextAttributes.cpp (#56047)
Summary: Pull Request resolved: #56047 Fixes: 1. **bugprone-use-after-move** (JSINativeModules.cpp:61): `moduleName` was used after being moved into `m_objects.emplace()`. The perf logger call now reads the module name from the map iterator (`result->first`) instead of the moved-from string. 2. **bugprone-optional-value-conversion** (TextAttributes.cpp:91): Unnecessary `optional<Size> -> Size -> optional<Size>` round-trip via `.value()`. Changed to assign the optional directly, matching the pattern used by all surrounding fields. Changelog: [Internal] Reviewed By: vzaidman Differential Revision: D95760414 fbshipit-source-id: 0c35415bbb27b8827a31a13d91c1e933fcfb6aa7
1 parent 116ea59 commit d177839

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

packages/react-native/ReactCommon/jsiexecutor/jsireact/JSINativeModules.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Value JSINativeModules::getModule(Runtime& rt, const PropNameID& name) {
5858
m_objects.emplace(std::move(moduleName), std::move(*module)).first;
5959

6060
Value ret = Value(rt, result->second);
61-
BridgeNativeModulePerfLogger::moduleJSRequireEndingEnd(moduleName.c_str());
61+
BridgeNativeModulePerfLogger::moduleJSRequireEndingEnd(result->first.c_str());
6262
return ret;
6363
}
6464

packages/react-native/ReactCommon/react/renderer/attributedstring/TextAttributes.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ void TextAttributes::apply(TextAttributes textAttributes) {
8888

8989
// Shadow
9090
textShadowOffset = textAttributes.textShadowOffset.has_value()
91-
? textAttributes.textShadowOffset.value()
91+
? textAttributes.textShadowOffset
9292
: textShadowOffset;
9393
textShadowRadius = !std::isnan(textAttributes.textShadowRadius)
9494
? textAttributes.textShadowRadius

0 commit comments

Comments
 (0)