Avoid unnecessary arrays

This commit is contained in:
mmd-osm 2019-06-27 18:33:12 +02:00
parent d0de9967b9
commit cf3cf5216f
11 changed files with 12 additions and 18 deletions

View file

@ -31,7 +31,7 @@ module Api
response.last_modified = node.timestamp
if node.visible
@nodes = [node]
@node = node
# Render the result
respond_to do |format|

View file

@ -28,11 +28,7 @@ module Api
@elements.unredacted
end
@elems = []
visible_elements.each do |element|
@elems << element
end
@elems = visible_elements
# Render the result
respond_to do |format|
@ -47,8 +43,6 @@ module Api
else
response.last_modified = @old_element.timestamp
@elems = [@old_element]
# Render the result
respond_to do |format|
format.xml

View file

@ -25,7 +25,7 @@ module Api
relation = Relation.find(params[:id])
response.last_modified = relation.timestamp
if relation.visible
@relations = [relation]
@relation = relation
# Render the result
respond_to do |format|

View file

@ -27,7 +27,7 @@ module Api
response.last_modified = way.timestamp
if way.visible
@ways = [way]
@way = way
# Render the result
respond_to do |format|
@ -80,7 +80,7 @@ module Api
end
end
@ways = [way]
@way = way
# Render the result
respond_to do |format|

View file

@ -1,5 +1,5 @@
xml.instruct!
xml.osm(OSM::API.new.xml_root_attributes) do |osm|
osm << (render(@nodes) || "")
osm << (render(@node) || "")
end

View file

@ -1,5 +1,5 @@
xml.instruct!
xml.osm(OSM::API.new.xml_root_attributes) do |osm|
osm << (render(@elems) || "")
osm << (render(@old_element) || "")
end

View file

@ -1,5 +1,5 @@
xml.instruct!
xml.osm(OSM::API.new.xml_root_attributes) do |osm|
osm << (render(@elems) || "")
osm << (render(@old_element) || "")
end

View file

@ -1,5 +1,5 @@
xml.instruct!
xml.osm(OSM::API.new.xml_root_attributes) do |osm|
osm << (render(@elems) || "")
osm << (render(@old_element) || "")
end

View file

@ -1,5 +1,5 @@
xml.instruct!
xml.osm(OSM::API.new.xml_root_attributes) do |osm|
osm << (render(@relations) || "")
osm << (render(@relation) || "")
end

View file

@ -2,5 +2,5 @@ xml.instruct!
xml.osm(OSM::API.new.xml_root_attributes) do |osm|
osm << (render(@nodes) || "")
osm << (render(@ways) || "")
osm << (render(@way) || "")
end

View file

@ -1,5 +1,5 @@
xml.instruct!
xml.osm(OSM::API.new.xml_root_attributes) do |osm|
osm << (render(@ways) || "")
osm << (render(@way) || "")
end