Skip to content

Commit

Permalink
lift isSyncModule_ check outside of isMethodSync (facebook#39590)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: facebook#39590

Changelog: [Internal]

some cleanup!

Differential Revision: D49521863

fbshipit-source-id: 22c41e3987719ebf15f1567ac03d12a76fa6e5f8
  • Loading branch information
philIip authored and facebook-github-bot committed Sep 21, 2023
1 parent 68c456d commit 9313991
Showing 1 changed file with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ id convertJSIValueToObjCObject(jsi::Runtime &runtime, const jsi::Value &value, s
return true;
}

return isSyncModule_ || !(returnType == VoidKind || returnType == PromiseKind);
return !(returnType == VoidKind || returnType == PromiseKind);
}

ObjCTurboModule::ObjCTurboModule(const InitParams &params)
Expand All @@ -707,15 +707,17 @@ id convertJSIValueToObjCObject(jsi::Runtime &runtime, const jsi::Value &value, s
const char *moduleName = name_.c_str();
const char *methodName = methodNameStr.c_str();

if (isMethodSync(returnType)) {
bool isSyncInvocation = isSyncModule_ || isMethodSync(returnType);

if (isSyncInvocation) {
TurboModulePerfLogger::syncMethodCallStart(moduleName, methodName);
} else {
TurboModulePerfLogger::asyncMethodCallStart(moduleName, methodName);
}

NSMutableArray *retainedObjectsForInvocation = [NSMutableArray arrayWithCapacity:count + 2];
NSInvocation *inv = createMethodInvocation(
runtime, isMethodSync(returnType), methodName, selector, args, count, retainedObjectsForInvocation);
runtime, isSyncInvocation, methodName, selector, args, count, retainedObjectsForInvocation);

jsi::Value returnValue = jsi::Value::undefined();

Expand All @@ -730,24 +732,24 @@ id convertJSIValueToObjCObject(jsi::Runtime &runtime, const jsi::Value &value, s
[retainedObjectsForInvocation addObject:resolveCopy];
[retainedObjectsForInvocation addObject:rejectCopy];
// The return type becomes void in the ObjC side.
performMethodInvocation(runtime, isMethodSync(VoidKind), methodName, inv, retainedObjectsForInvocation);
performMethodInvocation(runtime, isSyncInvocation, methodName, inv, retainedObjectsForInvocation);
});
} else {
id result =
performMethodInvocation(runtime, isMethodSync(returnType), methodName, inv, retainedObjectsForInvocation);
performMethodInvocation(runtime, isSyncInvocation, methodName, inv, retainedObjectsForInvocation);

if (isMethodSync(returnType)) {
if (isSyncInvocation) {
TurboModulePerfLogger::syncMethodCallReturnConversionStart(moduleName, methodName);
}

returnValue = convertReturnIdToJSIValue(runtime, methodName, returnType, result);

if (isMethodSync(returnType)) {
if (isSyncInvocation) {
TurboModulePerfLogger::syncMethodCallReturnConversionEnd(moduleName, methodName);
}
}

if (isMethodSync(returnType)) {
if (isSyncInvocation) {
TurboModulePerfLogger::syncMethodCallEnd(moduleName, methodName);
} else {
TurboModulePerfLogger::asyncMethodCallEnd(moduleName, methodName);
Expand Down

0 comments on commit 9313991

Please sign in to comment.