[openstreetmap/openstreetmap-website] Changeset: avoid XML rendering in loop (PR #5045)
Anton Khorev
notifications at github.com
Tue Aug 6 00:08:59 UTC 2024
@AntonKhorev commented on this pull request.
> xml.osm(OSM::API.new.xml_root_attributes) do |osm|
- @changesets.each do |changeset|
- osm << render(changeset)
- end
+ osm << (render(@changesets) || "")
Do we need this `|| ""`?
`render(@changesets)` returns `nil` on empty set, then `nil` gets appended to a stream which should work fine:
https://github.com/rails/builder/blob/789896b306e36a5fe166388413b16e9323260601/lib/builder/xmlbase.rb#L116
https://github.com/rails/rails/blob/9ba208c16835f4a174ae9fd385ebc18972d758a4/actionview/lib/action_view/buffers.rb#L97
--
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/5045#pullrequestreview-2220031870
You are receiving this because you are subscribed to this thread.
Message ID: <openstreetmap/openstreetmap-website/pull/5045/review/2220031870 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20240805/ab67b351/attachment.htm>
More information about the rails-dev
mailing list