lua: exit earlier when possible

This commit is contained in:
Emil Tin 2016-11-12 22:59:28 +01:00 committed by Patrick Niklaus
parent c3aeef4e09
commit 9e361a8178

View File

@ -371,8 +371,9 @@ end
-- handling ferries and piers -- handling ferries and piers
function handle_ferries(way,result,cache) function handle_ferries(way,result,cache)
local route = TagCache.get(way,cache,"route") local route = TagCache.get(way,cache,"route")
if route then
local route_speed = speed_profile[route] local route_speed = speed_profile[route]
if (route_speed and route_speed > 0) then if route_speed and route_speed > 0 then
local duration = TagCache.get(way,cache,"duration") local duration = TagCache.get(way,cache,"duration")
if duration and durationIsValid(duration) then if duration and durationIsValid(duration) then
result.duration = max( parseDuration(duration), 1 ) result.duration = max( parseDuration(duration), 1 )
@ -382,14 +383,17 @@ function handle_ferries(way,result,cache)
result.forward_speed = route_speed result.forward_speed = route_speed
result.backward_speed = route_speed result.backward_speed = route_speed
end end
end
end end
-- handling movable bridges -- handling movable bridges
function handle_movables(way,result,cache) function handle_movables(way,result,cache)
local bridge = TagCache.get(way,cache,"bridge") local bridge = TagCache.get(way,cache,"bridge")
if bridge then
local bridge_speed = speed_profile[bridge] local bridge_speed = speed_profile[bridge]
if bridge_speed and bridge_speed > 0 then
local capacity_car = TagCache.get(way,cache,"capacity:car") local capacity_car = TagCache.get(way,cache,"capacity:car")
if (bridge_speed and bridge_speed > 0) and (capacity_car ~= 0) then if capacity_car ~= 0 then
local duration = TagCache.get(way,cache,"duration") local duration = TagCache.get(way,cache,"duration")
if duration and durationIsValid(duration) then if duration and durationIsValid(duration) then
result.duration = max( parseDuration(duration), 1 ) result.duration = max( parseDuration(duration), 1 )
@ -397,6 +401,8 @@ function handle_movables(way,result,cache)
result.forward_speed = bridge_speed result.forward_speed = bridge_speed
result.backward_speed = bridge_speed result.backward_speed = bridge_speed
end end
end
end
end end
-- handle speed (excluding maxspeed) -- handle speed (excluding maxspeed)