aboutsummaryrefslogtreecommitdiff
path: root/ride/fit.go
diff options
context:
space:
mode:
authorMartin Kagamino Lehoux <martin@lehoux.net>2026-09-25 08:57:10 +0200
committerMartin Kagamino Lehoux <martin@lehoux.net>2026-09-25 08:57:10 +0200
commit0eadc1fde03153ff4b60655f15ed86367dc6a3d3 (patch)
tree00e8f42b983b665992a514bc715d92a96b4331c7 /ride/fit.go
parent077aa1700fbcaf3f499c2178e0e58e89ae9dcaf8 (diff)
Apply go fix modernizations
Embedded composite literals and min/max clamp idioms, as rewritten by the go fix step of mise check.
Diffstat (limited to 'ride/fit.go')
-rw-r--r--ride/fit.go20
1 files changed, 4 insertions, 16 deletions
diff --git a/ride/fit.go b/ride/fit.go
index 760cec1..db9c0b6 100644
--- a/ride/fit.go
+++ b/ride/fit.go
@@ -157,36 +157,24 @@ func EncodeFIT(ride Ride, w io.Writer) error {
rec.PositionLong = fit.NewLongitudeDegrees(coord.Lon)
// Altitude: scaled (value+500)*5, invalid 0xFFFF
elev := ride.Elevations[i]
- scaled := max(int((elev+500)*5), 0)
- if scaled > 0xFFFE {
- scaled = 0xFFFE
- }
+ scaled := min(max(int((elev+500)*5), 0), 0xFFFE)
rec.Altitude = uint16(scaled)
rec.EnhancedAltitude = 0xFFFFFFFF
if hasHR {
- v := max(int(heartRates[i]), 0)
- if v > 254 {
- v = 254
- }
+ v := min(max(int(heartRates[i]), 0), 254)
rec.HeartRate = uint8(v)
} else {
rec.HeartRate = 0xFF
}
if hasCad {
- v := max(int(cadences[i]), 0)
- if v > 254 {
- v = 254
- }
+ v := min(max(int(cadences[i]), 0), 254)
rec.Cadence = uint8(v)
} else {
rec.Cadence = 0xFF
}
if hasPower {
- v := max(int(powers[i]), 0)
- if v > 65534 {
- v = 65534
- }
+ v := min(max(int(powers[i]), 0), 65534)
rec.Power = uint16(v)
} else {
rec.Power = 0xFFFF