Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: make debug-print of StreamProtocol more concise #4631

Merged
merged 6 commits into from
Oct 13, 2023

Conversation

thomaseizinger
Copy link
Contributor

Description

The fmt::Debug implementation of a type should in most cases reveal its internal structure. StreamProtocol is likely to be debug-printed a lot and in many cases, the only contract is the fmt::Debug impl. The internals of StreamProtocol only exist for performance reasons to avoid allocations for statically-known protocol strings. Revealing this implementation detail isn't particularly beneficial to end users. At the same time, the current implementation is very noise.

Previously, the protocols field of an identify::Info would e.g. read as:

protocols: [StreamProtocol { inner: Right("/ipfs/id/1.0.0") }, StreamProtocol { inner: Right("/ipfs/id/push/1.0.0") }, StreamProtocol { inner: Right("/ipfs/kad/1.0.0") }]

With this patch, it reads as:

protocols: ["/ipfs/id/1.0.0", "/ipfs/kad/1.0.0", "/ipfs/id/push/1.0.0"]

Notes & open questions

Change checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • A changelog entry has been made in the appropriate crates

swarm/CHANGELOG.md Outdated Show resolved Hide resolved
@thomaseizinger thomaseizinger added send-it trivial Marks PRs which are considered trivial and don't need approval from another maintainer. labels Oct 13, 2023
@mergify mergify bot merged commit 6aa805d into master Oct 13, 2023
73 checks passed
@mergify mergify bot deleted the refactor/dbg-print-stream-protocol branch October 13, 2023 05:23
Copy link
Member

@mxinden mxinden left a comment

Choose a reason for hiding this comment

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

🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
send-it trivial Marks PRs which are considered trivial and don't need approval from another maintainer.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants