Closed pierrre closed 3 years ago
wspBuf
could be replaced with a wsp bool
field, since we never use the actual value. Your suggestion looks like a good idea for crlfBuf
.
Patches welcome!
wspBuf could be replaced with a wsp bool field
Yes I noticed that too :sweat_smile:
I'll work on it tomorrow.
Here is the PR https://github.com/emersion/go-msgauth/pull/47
In my application, nearly 50% of my memory allocations (in count) are caused by
relaxedBodyCanonicalizer
. https://github.com/emersion/go-msgauth/blob/6dd5b6c922fa55520e0bf188c91156624b737cc7/dkim/canonical.go#L130-L158 Especially lines 146 and 149.I think this code could be optimized. Currently each call to
append
causes a new memory allocation and requires to copy the memory. Because the slices are reset to nil. It doesn't reuse the memory previously allocated. The solution: doc.wspBuf = c.wspBuf[:0]
instead ofc.wspBuf = nil
. Same forcrlfBuf
.WDYT ?