mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-05-12 19:48:30 +08:00
Skip unnecessary string allocs from frquently executed code paths.
Differential Revision: D2540814 fb-gh-sync-id: 045d012b52a6bc89d409bcc028532da1760c5775
This commit is contained in:
committed by
facebook-github-bot-6
parent
aae9f0255f
commit
10a9b94b9c
@@ -66,7 +66,9 @@ class JavaScriptModuleRegistration {
|
||||
|
||||
public int getMethodId(Method method) {
|
||||
final Integer id = mMethodsToIds.get(method);
|
||||
Assertions.assertNotNull(id, "Unknown method: " + method.getName());
|
||||
if (id == null) {
|
||||
Assertions.assertUnreachable("Unknown method: " + method.getName());
|
||||
}
|
||||
return id.intValue();
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,15 @@ import javax.annotation.Nullable;
|
||||
*/
|
||||
public class SoftAssertions {
|
||||
|
||||
/**
|
||||
* Throw {@link AssertionException} with a given message. Use this method surrounded with
|
||||
* {@code if} block with assert condition in case you plan to do string concatenation to produce
|
||||
* the message.
|
||||
*/
|
||||
public static void assertUnreachable(String message) {
|
||||
throw new AssertionException(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts the given condition, throwing an {@link AssertionException} if the condition doesn't
|
||||
* hold.
|
||||
|
||||
Reference in New Issue
Block a user