Skip to content

Conversation

@JensRantil
Copy link
Contributor

Fixes a TODO. Worth it?

There are various approaches to it, though:

 * Have a buffer for each `Email` instance. This would make `Email` not
   being thread-safe anymore.
 * Have a `sync.Pool` containing `bytes.Buffer` instances. This is
   probably a better approach with fewer surprises for users of this
   library. Assuming that this would be a non-exported field on `Email`,
   this would mean that `EMail` can't be instantiated using `Email{...}`
   anymore, which might not be what we want? At least it'll be a
   compilation error, though. Workaround for this issue would be to use
   a `sync.Once` to make sure to instantiate the pool.
Reduces memory allocation and fixes a TODO.
sps, err := parseMIMEParts(p.Header, p)
sps, err := parseMIMEParts(p.Header, p, bufPool)
if err != nil {
return ps, err
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe also hand back when returning?

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.

1 participant