]> Cypherpunks repositories - gostls13.git/commit
fmt: make recursive scan more efficient.
authorRoger Peppe <rogpeppe@gmail.com>
Thu, 3 Mar 2011 18:43:29 +0000 (10:43 -0800)
committerRob Pike <r@golang.org>
Thu, 3 Mar 2011 18:43:29 +0000 (10:43 -0800)
commit5bd284e86840eba5e4ace473a3f7341a40332db6
tree007b027a4dcb82fb22f83aa7a60f44954a81962c
parente46acb091fa7dfbdb99e61801f37522bd8b80365
fmt: make recursive scan more efficient.
Detect when scan is being called recursively and
re-use the same scan state.

On my machine, for a recursion-heavy benchmark, this
results in 44x speed up. This does impose a 4% penalty
on the non-recursive case, which can be removed by
heap-allocating the saved state, at 40% performance penalty
on the recursive case. Either way is fine with me.

R=r
CC=golang-dev
https://golang.org/cl/4253049
src/pkg/fmt/scan.go
src/pkg/fmt/scan_test.go