diff options
author | Sean E. Russell <ser@ser1.net> | 2021-01-26 16:16:48 -0600 |
---|---|---|
committer | Sean E. Russell <ser@ser1.net> | 2021-01-26 16:16:48 -0600 |
commit | af20668cb5746018e316b1ae4007e6ac54f608a5 (patch) | |
tree | 38f29d234b7454d08bfe024c028444a6d9ac9279 | |
parent | c8f70919695dd2b298af144f156fb740b90d7f54 (diff) |
strings.TrimSuffix() is some 7x faster than a call to Index() plus a slice, and we can remove a call to Contains() in the bargain.
-rw-r--r-- | devices/temp_linux.go | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/devices/temp_linux.go b/devices/temp_linux.go index b738002..c0f4cae 100644 --- a/devices/temp_linux.go +++ b/devices/temp_linux.go @@ -25,9 +25,7 @@ func devs() []string { rv := make([]string, 0, len(sensors)) for _, sensor := range sensors { label := sensor.SensorKey - if strings.Contains(sensor.SensorKey, "input") { - label = sensor.SensorKey[:strings.Index(sensor.SensorKey, "_input")] - } + label = strings.TrimSuffix(sensor.SensorKey, "_input") rv = append(rv, label) sensorMap[sensor.SensorKey] = label } |