]> git.openstreetmap.org Git - rails.git/commitdiff
Use filter instead of loop in visible node/way collections
authorAnton Khorev <tony29@yandex.ru>
Sat, 1 Feb 2025 17:19:00 +0000 (20:19 +0300)
committerAnton Khorev <tony29@yandex.ru>
Sat, 1 Feb 2025 17:19:00 +0000 (20:19 +0300)
app/controllers/api/maps_controller.rb

index c37ba2a3e405fe04b18fca246341d22325c59785..9ba95c2551b650cfaccf0aa3c91f171a98e84238 100644 (file)
@@ -57,15 +57,9 @@ module Api
 
       nodes += Node.includes(:node_tags).find(nodes_to_fetch) unless nodes_to_fetch.empty?
 
-      @nodes = []
-      nodes.each do |node|
-        @nodes << node if node.visible?
-      end
+      @nodes = nodes.filter(&:visible?)
 
-      @ways = []
-      ways.each do |way|
-        @ways << way if way.visible?
-      end
+      @ways = ways.filter(&:visible?)
 
       @relations = Relation.nodes(@nodes).visible +
                    Relation.ways(@ways).visible