aboutsummaryrefslogtreecommitdiffstats
path: root/prog/rand.go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2020-07-02 17:41:48 +0200
committerDmitry Vyukov <dvyukov@google.com>2020-07-04 15:05:30 +0200
commitfcb219b67eb296b6781f81074e9cb5b09163f734 (patch)
treecb9adbc1e3df32449593f0da45d60fb6c161e07e /prog/rand.go
parent74cb4e09a50b0f8cc45fce9ac072d1079eb03b42 (diff)
all: don't compare string len with 0
For strings it's more readable to compare the string itself with "", instead of comparing len with 0. Fix all such cases. Update #1876
Diffstat (limited to 'prog/rand.go')
-rw-r--r--prog/rand.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/prog/rand.go b/prog/rand.go
index a6c013fdd..5ff448062 100644
--- a/prog/rand.go
+++ b/prog/rand.go
@@ -249,7 +249,7 @@ func (r *randGen) flags(vv []uint64, bitmask bool, oldVal uint64) uint64 {
func (r *randGen) filename(s *state, typ *BufferType) string {
fn := r.filenameImpl(s)
- if len(fn) != 0 && fn[len(fn)-1] == 0 {
+ if fn != "" && fn[len(fn)-1] == 0 {
panic(fmt.Sprintf("zero-terminated filename: %q", fn))
}
if escapingFilename(fn) {
@@ -284,7 +284,7 @@ func (r *randGen) filenameImpl(s *state) string {
dir := "."
if r.oneOf(2) && len(s.files) != 0 {
dir = r.randFromMap(s.files)
- if len(dir) > 0 && dir[len(dir)-1] == 0 {
+ if dir != "" && dir[len(dir)-1] == 0 {
dir = dir[:len(dir)-1]
}
if r.oneOf(10) && filepath.Clean(dir)[0] != '.' {