From a766b9b9f87ea43c944d53505f191eebedb3f30a Mon Sep 17 00:00:00 2001 From: Christina Date: Wed, 18 Dec 2024 13:52:19 +0100 Subject: [PATCH] remove excess write and rewind in exchange --- src/lavinmq/mqtt/exchange.cr | 5 +---- src/lavinmq/mqtt/session.cr | 1 - 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/lavinmq/mqtt/exchange.cr b/src/lavinmq/mqtt/exchange.cr index c79641425f..ceddf3631b 100644 --- a/src/lavinmq/mqtt/exchange.cr +++ b/src/lavinmq/mqtt/exchange.cr @@ -50,10 +50,7 @@ module LavinMQ timestamp = RoughTime.unix_ms bodysize = packet.payload.size.to_u64 - body = ::IO::Memory.new(bodysize) - body.write(packet.payload) - body.rewind - + body = ::IO::Memory.new(packet.payload, false) if packet.retain? @retain_store.retain(packet.topic, body, bodysize) body.rewind diff --git a/src/lavinmq/mqtt/session.cr b/src/lavinmq/mqtt/session.cr index 65b3dadef9..2c03a3b38f 100644 --- a/src/lavinmq/mqtt/session.cr +++ b/src/lavinmq/mqtt/session.cr @@ -145,7 +145,6 @@ module LavinMQ def build_packet(env, packet_id) : MQTT::Publish msg = env.message retained = msg.properties.try &.headers.try &.["mqtt.retain"]? == true - qos = msg.properties.delivery_mode || 0u8 qos = 1u8 if qos > 1 MQTT::Publish.new(