philadelphia-core: Optimize 'FIXConnection#updateCompID'
Remove explicit null checks. This reduces the bytecode size from 45
bytes to 27 bytes, which is under HotSpot's default maximum inline
size of 35 bytes.
Note. This is an API change as this method will no longer throw
an 'InvalidStateException' but might throw a 'NullPointerException'
instead.
@@ -287,23 +287,12 @@ public class FIXConnection implements Closeable {
* Update SenderCompID(49) and TargetCompID(56).
*
* @param message a message
- * @throws IllegalStateException if SenderCompID(49) or TargetCompID(56)
+ * @throws NullPointerException if SenderCompID(49) or TargetCompID(56)
* is not found
*/
public void updateCompID(FIXMessage message) {
- FIXValue value;
-
- value = message.valueOf(SenderCompID);
- if (value == null)
- senderCompIDNotFound();
-
- value.setString(senderCompId);
-
- value = message.valueOf(TargetCompID);
- if (value == null)
- targetCompIDNotFound();
-
- value.setString(targetCompId);
+ message.valueOf(SenderCompID).setString(senderCompId);
+ message.valueOf(TargetCompID).setString(targetCompId);
}
/**
@@ -724,14 +713,6 @@ public class FIXConnection implements Closeable {
send(txMessage);
}
- private static void senderCompIDNotFound() {
- throw new IllegalStateException("SenderCompID(49) not found");
- }
-
- private static void targetCompIDNotFound() {
- throw new IllegalStateException("TargetCompID(56) not found");
- }
-
private static void tooLongMessage() throws FIXMessageOverflowException {
throw new FIXMessageOverflowException("Too long message");
}
