Avoid unnecessary arrays
authormmd-osm <mmd.osm@gmail.com>
Thu, 27 Jun 2019 16:33:12 +0000 (18:33 +0200)
committermmd-osm <mmd.osm@gmail.com>
Thu, 27 Jun 2019 16:33:12 +0000 (18:33 +0200)
app/controllers/api/nodes_controller.rb
app/controllers/api/old_controller.rb
app/controllers/api/relations_controller.rb
app/controllers/api/ways_controller.rb
app/views/api/nodes/show.xml.builder
app/views/api/old_nodes/version.xml.builder
app/views/api/old_relations/version.xml.builder
app/views/api/old_ways/version.xml.builder
app/views/api/relations/show.xml.builder
app/views/api/ways/full.xml.builder
app/views/api/ways/show.xml.builder

index 630149a749b270b3b36bc074a6afecdff9189be4..891528a5f5790c73ef3a90349a300e4cb569d40a 100644 (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|
index 39bb35ca9f05757c2ac6d4df4d710c411e685010..bf3fcdb39ee1a725f814cefa25d17727eb52b4bd 100644 (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
index 9f125cfd3d83365e4e10b9155822d1f9b438d1cb..40d919ddc698b43ac75c3a97b513805306f28376 100644 (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|
index b8ce1010f29cc1e3fa046c67b78a1733882892c8..04c823ad2a40e2b5db5835509688baf3c2da8b79 100644 (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|
index 1968de97a73ac8bb80354866beaaa19c631f5a3f..48f7e314ad6203b1d207d5615230d9ca33274ab1 100644 (file)
@@ -1,5 +1,5 @@
 xml.instruct!
 
 xml.osm(OSM::API.new.xml_root_attributes) do |osm|
-  osm << (render(@nodes) || "")
+  osm << (render(@node) || "")
 end
index 905381ce9020020a35daabcf01c3a6cc09fa9130..c7b630d3adb08e10e25575eab426a6165176ce33 100644 (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
index 905381ce9020020a35daabcf01c3a6cc09fa9130..c7b630d3adb08e10e25575eab426a6165176ce33 100644 (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
index 905381ce9020020a35daabcf01c3a6cc09fa9130..c7b630d3adb08e10e25575eab426a6165176ce33 100644 (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
index f39a20bb937a3fd9c5ece31fcd024a83c7b22a6d..555eb4db5f73d5a53bcd41b9222bac4f758e6003 100644 (file)
@@ -1,5 +1,5 @@
 xml.instruct!
 
 xml.osm(OSM::API.new.xml_root_attributes) do |osm|
-  osm << (render(@relations) || "")
+  osm << (render(@relation) || "")
 end
index d8b3aea803b6217bae2e665361ae72ef03873d52..025291638c7efeda7ec9a1efb740d6037bddc908 100644 (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
index bcb89cdc6c4050e113e97845ca8a5676e45325d5..d520a08444376f96f25a5eb93099fb43e70bd526 100644 (file)
@@ -1,5 +1,5 @@
 xml.instruct!
 
 xml.osm(OSM::API.new.xml_root_attributes) do |osm|
-  osm << (render(@ways) || "")
+  osm << (render(@way) || "")
 end