diff options
author | Michael Stapelberg <stapelberg@debian.org> | 2014-06-19 09:22:53 +0200 |
---|---|---|
committer | Michael Stapelberg <stapelberg@debian.org> | 2014-06-19 09:22:53 +0200 |
commit | 8a39ee361feb9bf46d728ff1ba4f07ca1d9610b1 (patch) | |
tree | 4449f2036cccf162e8417cc5841a35815b3e7ac5 /src/pkg/fmt/scan.go | |
parent | c8bf49ef8a92e2337b69c14b9b88396efe498600 (diff) | |
download | golang-upstream/1.3.tar.gz |
Imported Upstream version 1.3upstream/1.3
Diffstat (limited to 'src/pkg/fmt/scan.go')
-rw-r--r-- | src/pkg/fmt/scan.go | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/pkg/fmt/scan.go b/src/pkg/fmt/scan.go index 5b1be5891..8a337e479 100644 --- a/src/pkg/fmt/scan.go +++ b/src/pkg/fmt/scan.go @@ -11,6 +11,7 @@ import ( "os" "reflect" "strconv" + "sync" "unicode/utf8" ) @@ -283,7 +284,6 @@ var space = [][2]uint16{ {0x0085, 0x0085}, {0x00a0, 0x00a0}, {0x1680, 0x1680}, - {0x180e, 0x180e}, {0x2000, 0x200a}, {0x2028, 0x2029}, {0x202f, 0x202f}, @@ -380,7 +380,9 @@ func (r *readRune) ReadRune() (rr rune, size int, err error) { return } -var ssFree = newCache(func() interface{} { return new(ss) }) +var ssFree = sync.Pool{ + New: func() interface{} { return new(ss) }, +} // newScanState allocates a new ss struct or grab a cached one. func newScanState(r io.Reader, nlIsSpace, nlIsEnd bool) (s *ss, old ssave) { @@ -395,7 +397,7 @@ func newScanState(r io.Reader, nlIsSpace, nlIsEnd bool) (s *ss, old ssave) { return } - s = ssFree.get().(*ss) + s = ssFree.Get().(*ss) if rr, ok := r.(io.RuneReader); ok { s.rr = rr } else { @@ -427,7 +429,7 @@ func (s *ss) free(old ssave) { } s.buf = s.buf[:0] s.rr = nil - ssFree.put(s) + ssFree.Put(s) } // skipSpace skips spaces and maybe newlines. |