perf: remove unneeded branching in message handling code