philadelphia-core: Optimize 'FIXConnection#update'
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.
@@ -275,21 +275,12 @@ public class FIXConnection implements Closeable {
* </ul>
*
* @param message a message
- * @throws IllegalStateException if MsgSeqNum(34) or SendingTime(52) is
+ * @throws NullPointerException if MsgSeqNum(34) or SendingTime(52) is
* not found
*/
public void update(FIXMessage message) {
- FIXValue msgSeqNum = message.valueOf(MsgSeqNum);
- if (msgSeqNum == null)
- msgSeqNumNotFound();
-
- msgSeqNum.setInt(txMsgSeqNum);
-
- FIXValue sendingTime = message.valueOf(SendingTime);
- if (sendingTime == null)
- sendingTimeNotFound();
-
- sendingTime.setString(currentTimestamp);
+ message.valueOf(MsgSeqNum).setInt(txMsgSeqNum);
+ message.valueOf(SendingTime).setString(currentTimestamp);
}
/**
@@ -733,14 +724,6 @@ public class FIXConnection implements Closeable {
send(txMessage);
}
- private static void msgSeqNumNotFound() {
- throw new IllegalStateException("MsgSeqNum(34) not found");
- }
-
- private static void sendingTimeNotFound() {
- throw new IllegalStateException("SendingTime(52) not found");
- }
-
private static void senderCompIDNotFound() {
throw new IllegalStateException("SenderCompID(49) not found");
}
