]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: minor cleanup in debug code
authorJosh Bleecher Snyder <josharian@gmail.com>
Sat, 18 Mar 2017 00:09:07 +0000 (17:09 -0700)
committerJosh Bleecher Snyder <josharian@gmail.com>
Fri, 24 Mar 2017 22:21:55 +0000 (22:21 +0000)
Change-Id: I9885606801b9c8fcb62c16d0856025c4e83e658b
Reviewed-on: https://go-review.googlesource.com/38650
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/cmd/compile/internal/ssa/func.go

index d37540e180c0acb2da89e1d1023883806af9651f..17860957cff5dc42c2894528c075cc5c2851e85b 100644 (file)
@@ -551,14 +551,13 @@ func (f *Func) invalidateCFG() {
 // opening the file.
 func (f *Func) DebugHashMatch(evname, name string) bool {
        evhash := os.Getenv(evname)
-       if evhash == "" {
+       switch evhash {
+       case "":
                return true // default behavior with no EV is "on"
-       }
-       if evhash == "y" || evhash == "Y" {
+       case "y", "Y":
                f.logDebugHashMatch(evname, name)
                return true
-       }
-       if evhash == "n" || evhash == "N" {
+       case "n", "N":
                return false
        }
        // Check the hash of the name against a partial input hash.
@@ -597,11 +596,10 @@ func (f *Func) logDebugHashMatch(evname, name string) {
        file := f.logfiles[evname]
        if file == nil {
                file = os.Stdout
-               tmpfile := os.Getenv("GSHS_LOGFILE")
-               if tmpfile != "" {
-                       var ok error
-                       file, ok = os.Create(tmpfile)
-                       if ok != nil {
+               if tmpfile := os.Getenv("GSHS_LOGFILE"); tmpfile != "" {
+                       var err error
+                       file, err = os.Create(tmpfile)
+                       if err != nil {
                                f.Fatalf("could not open hash-testing logfile %s", tmpfile)
                        }
                }