Closed kevinburke closed 8 years ago
cool! i wonder if there are some additional wins we could make:
memcpy
Also casting string to bytes and vice versa (return string(e.Bytes()[start:stop])
) could be easily avoided by writing quotes only if needsQuotes
is set and returning e.String()
directly.
@tg yeah, you're absolutely right. we should actually see if we can rewrite the formatter entirely to work entirely in bytes if possible to avoid any unnecessary conversions
I don't want to put a damper on all the great work being done here, but another alternative is to use the github.com/go-logfmt/logfmt package which has many of these ideas already incorporated. PRs on that package welcome for additional speedups.
argh! I had completely forgotten that you built that fantastic package. we should definitely be adopting that and not duplicate effort here =)
escapeString is expensive. Let's do one pass to check whether anything needs to be escaped - which may be a common case - then a second pass to allocate a buffer and do the escaping, if we need to.