Adding Java and C++ to the MQTT benchmarks or: How I Learned to Stop Worrying and Love the Garbage Collector
Atila Neves
atila.neves at gmail.com
Wed Jan 8 04:47:22 PST 2014
Thanks. I didn't think of using with, possibly because I've never
used it before. It's one of those cool little features that I
liked when I read about it but never remember about later.
I didn't use final switch on purpose; I normally would, but I
didn't implement all the possible MQTT message types. If I ever
do, it'll definitely be a final switch.
Atila
On Wednesday, 8 January 2014 at 12:35:02 UTC, bearophile wrote:
> Atila Neves:
>
>> http://atilanevesoncode.wordpress.com/2014/01/08/adding-java-and-c-to-the-mqtt-benchmarks-or-how-i-learned-to-stop-worrying-and-love-the-garbage-collector/
>
> In this file:
> https://github.com/atilaneves/mqtt/blob/master/mqttd/factory.d
>
> Instead of code:
>
> switch(fixedHeader.type) {
> case MqttType.CONNECT:
> return cereal.value!MqttConnect(fixedHeader);
> case MqttType.CONNACK:
>
>
> Perhaps you want code as:
>
> final switch(fixedHeader.type) with (MqttType) {
> case CONNECT:
> return cereal.value!MqttConnect(fixedHeader);
> case CONNACK:
> ...
>
>
> Or even (modifying the enum):
>
> final switch(fixedHeader.type) with (MqttType) {
> case connect:
> return cereal.value!MqttConnect(fixedHeader);
> case connack:
> ...
>
>
> Bye,
> bearophile
More information about the Digitalmars-d
mailing list