src-d / go-git

Project has been moved to: https://github.com/go-git/go-git
https://github.com/go-git/go-git
Apache License 2.0
4.91k stars 541 forks source link

plumbing/object: avoid O(N^2) string building when decoding commit me… #1246

Open dsymonds opened 4 years ago

dsymonds commented 4 years ago

…ssage

Most commits have relatively small messages, so this was never noticeable. However, there are some repositories that have semi-automated messages that can get very large (e.g. github.com/riscv/riscv-clang and its riscv-trunk branch), on the order of 109k lines. Changing from string += to using a bytes.Buffer reduces the time for Commit.Decode for that specific case from 35s to 74ms.

Signed-off-by: David Symonds dsymonds@golang.org

dsymonds commented 4 years ago

Hey, any chance this'll get merged soon, @mcuadros @smola ?