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,31 +371,37 @@ 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")
local route_speed = speed_profile[route] if route then
if (route_speed and route_speed > 0) then local route_speed = speed_profile[route]
local duration = TagCache.get(way,cache,"duration") if route_speed and route_speed > 0 then
if duration and durationIsValid(duration) then local duration = TagCache.get(way,cache,"duration")
result.duration = max( parseDuration(duration), 1 ) if duration and durationIsValid(duration) then
end result.duration = max( parseDuration(duration), 1 )
result.forward_mode = mode.ferry end
result.backward_mode = mode.ferry result.forward_mode = mode.ferry
result.forward_speed = route_speed result.backward_mode = mode.ferry
result.backward_speed = route_speed result.forward_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")
local bridge_speed = speed_profile[bridge] if bridge then
local capacity_car = TagCache.get(way,cache,"capacity:car") local bridge_speed = speed_profile[bridge]
if (bridge_speed and bridge_speed > 0) and (capacity_car ~= 0) then if bridge_speed and bridge_speed > 0 then
local duration = TagCache.get(way,cache,"duration") local capacity_car = TagCache.get(way,cache,"capacity:car")
if duration and durationIsValid(duration) then if capacity_car ~= 0 then
result.duration = max( parseDuration(duration), 1 ) local duration = TagCache.get(way,cache,"duration")
if duration and durationIsValid(duration) then
result.duration = max( parseDuration(duration), 1 )
end
result.forward_speed = bridge_speed
result.backward_speed = bridge_speed
end
end end
result.forward_speed = bridge_speed
result.backward_speed = bridge_speed
end end
end end