Skip to content

Commit

Permalink
remove excess write and rewind in exchange
Browse files Browse the repository at this point in the history
  • Loading branch information
kickster97 committed Dec 18, 2024
1 parent 969b194 commit a766b9b
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 5 deletions.
5 changes: 1 addition & 4 deletions src/lavinmq/mqtt/exchange.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/lavinmq/mqtt/session.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit a766b9b

Please sign in to comment.