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

Optimize Entity.WriteTo when encoding/charset are unchanged #87

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

emersion
Copy link
Owner

Closes: #86

@codecov-io
Copy link

Codecov Report

Merging #87 into master will increase coverage by 0.20%.
The diff coverage is 95.65%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #87      +/-   ##
==========================================
+ Coverage   79.49%   79.70%   +0.20%     
==========================================
  Files          15       15              
  Lines         995     1005      +10     
==========================================
+ Hits          791      801      +10     
  Misses        128      128              
  Partials       76       76              
Impacted Files Coverage Δ
writer.go 72.54% <83.33%> (+1.12%) ⬆️
entity.go 93.22% <100.00%> (+1.06%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f828d02...584bd27. Read the comment docs.

@emersion
Copy link
Owner Author

emersion commented Apr 29, 2020

This doesn't work if Entity.Body is set to something else by the library user.

Comment on lines +124 to +125
} else if w.encoding == e.encoding && w.charset == e.charset {
_, err = io.Copy(w.rawWriter, e.originalBody)
Copy link
Collaborator

@foxcpp foxcpp Apr 29, 2020

Choose a reason for hiding this comment

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

Perhaps then this branch can also check whether e.Body was replaced by the user? Or, add a getter/setter pair for Body that will invalidate originalBody.

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.

Optimize Entity.WriteTo
3 participants