From 7df7d3ec87698999daf88d165a5d971611ee177d Mon Sep 17 00:00:00 2001 From: Marius Merschformann Date: Tue, 14 May 2024 14:19:55 +0200 Subject: [PATCH] Remove extra checks in value func --- model_expression_haversine.go | 6 +++--- model_expression_measure_byindex.go | 6 +++--- model_expression_measure_bypoint.go | 12 ++++++------ 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/model_expression_haversine.go b/model_expression_haversine.go index f1f5e98..b7f80f2 100644 --- a/model_expression_haversine.go +++ b/model_expression_haversine.go @@ -59,9 +59,9 @@ func (h *haversineExpression) Value( from ModelStop, to ModelStop, ) float64 { - if from == nil || to == nil || !from.Location().IsValid() || !to.Location().IsValid() { - return 0.0 - } + // if from == nil || to == nil || !from.Location().IsValid() || !to.Location().IsValid() { + // return 0.0 + // } return haversineDistance(from.Location(), to.Location()). Value(vehicle.Model().DistanceUnit()) } diff --git a/model_expression_measure_byindex.go b/model_expression_measure_byindex.go index 5d21813..6c565e5 100644 --- a/model_expression_measure_byindex.go +++ b/model_expression_measure_byindex.go @@ -52,8 +52,8 @@ func (m *measureByIndexExpression) SetName(n string) { } func (m *measureByIndexExpression) Value(_ ModelVehicleType, from, to ModelStop) float64 { - if from == nil || to == nil || !from.Location().IsValid() || !to.Location().IsValid() { - return 0.0 - } + // if from == nil || to == nil || !from.Location().IsValid() || !to.Location().IsValid() { + // return 0.0 + // } return m.measure.Cost(from.(*stopImpl).measureIndex, to.(*stopImpl).measureIndex) } diff --git a/model_expression_measure_bypoint.go b/model_expression_measure_bypoint.go index 7c5cd8c..bbed5f9 100644 --- a/model_expression_measure_bypoint.go +++ b/model_expression_measure_bypoint.go @@ -52,14 +52,14 @@ func (m *measureByPointExpression) SetName(n string) { } func (m *measureByPointExpression) Value(_ ModelVehicleType, from, to ModelStop) float64 { - if from == nil || to == nil { - return 0.0 - } + // if from == nil || to == nil { + // return 0.0 + // } locFrom := from.Location() locTo := to.Location() - if !locFrom.IsValid() || !locTo.IsValid() { - return 0.0 - } + // if !locFrom.IsValid() || !locTo.IsValid() { + // return 0.0 + // } value := m.measure.Cost( measure.Point{locFrom.Longitude(), locFrom.Latitude()}, measure.Point{locTo.Longitude(), locTo.Latitude()},