diff options
| author | cuiweixie <cuiweixie@gmail.com> | 2022-08-27 10:35:31 +0800 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2022-08-30 19:42:56 +0000 |
| commit | 8a3d167f5b4b482a230cd9800df9969af60561af (patch) | |
| tree | 5f8ada7dfe96cf35a3817b3370be614615d72146 /src/testing | |
| parent | 3c6a5cdb9a29c0e3b12cdaa8ab81ba22d989e3b0 (diff) | |
| download | go-8a3d167f5b4b482a230cd9800df9969af60561af.tar.xz | |
testing: increment tempDirSeq non-atomically
It's unnecessary to to call atomic.AddInt32 since there is a mutex lock.
Change-Id: I31fcece17c34f99a95772d744aebd3f6a8cf1d23
Reviewed-on: https://go-review.googlesource.com/c/go/+/426081
Reviewed-by: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Diffstat (limited to 'src/testing')
| -rw-r--r-- | src/testing/testing.go | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/testing/testing.go b/src/testing/testing.go index 7148537370..0228d2904b 100644 --- a/src/testing/testing.go +++ b/src/testing/testing.go @@ -1127,12 +1127,17 @@ func (c *common) TempDir() string { }) } } + + if c.tempDirErr == nil { + c.tempDirSeq++ + } + seq := c.tempDirSeq c.tempDirMu.Unlock() if c.tempDirErr != nil { c.Fatalf("TempDir: %v", c.tempDirErr) } - seq := atomic.AddInt32(&c.tempDirSeq, 1) + dir := fmt.Sprintf("%s%c%03d", c.tempDir, os.PathSeparator, seq) if err := os.Mkdir(dir, 0777); err != nil { c.Fatalf("TempDir: %v", err) |
