Skip to content

Conversation

@leshy
Copy link
Contributor

@leshy leshy commented Feb 9, 2026

Skip lcm_encode() when the message is already bytes, assume msg is already LCM encoded. small functionality for
#1222

Skip lcm_encode() when the message is already bytes,
avoiding unnecessary re-encoding.
@greptile-apps
Copy link

greptile-apps bot commented Feb 9, 2026

Greptile Overview

Greptile Summary

This change updates LCMEncoderMixin.encode() to accept either a DimosMsg or pre-encoded bytes. If the caller provides bytes, the encoder now passes them through unchanged; otherwise it encodes via msg.lcm_encode(). This avoids redundant LCM re-encoding for already-serialized payloads while keeping the existing decode() path (using topic.lcm_type.lcm_decode) unchanged.

No merge-blocking issues found in the change.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk.
  • The change is small and localized to LCMEncoderMixin.encode(), adds a straightforward bytes passthrough, and preserves existing behavior for DimosMsg encoding/decoding. No runtime regressions were found by tracing publish/subscribe flow and existing call patterns that already publish bytes.
  • No files require special attention

Important Files Changed

Filename Overview
dimos/protocol/pubsub/encoders.py LCMEncoderMixin.encode now accepts pre-encoded bytes and returns them directly; otherwise uses msg.lcm_encode(). No functional issues found.

Sequence Diagram

sequenceDiagram
    participant App as Publisher (app code)
    participant Enc as PubSubEncoderMixin.publish
    participant LcmEnc as LCMEncoderMixin.encode
    participant Base as LCMPubSubBase.publish
    participant LCM as LCM transport

    App->>Enc: publish(topic, message)
    Enc->>LcmEnc: encode(message, topic)
    alt message is bytes
        LcmEnc-->>Enc: return message (passthrough)
    else message is DimosMsg
        LcmEnc-->>Enc: return message.lcm_encode()
    end
    Enc->>Base: super().publish(topic, encoded_bytes)
    Base->>LCM: publish(topic.topic, encoded_bytes)

Loading

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

@paul-nechifor paul-nechifor merged commit dc2998d into dev Feb 11, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants