<p>When working on the lib/gpx.rb code I noticed that it repeatedly parses the XML file. This is because <code>gpx.points</code> is called from other methods, which rewinds the file pointer and parses the file all over again.</p>
<p>The advantage here is that we don't store the full list of parsed points in RAM, since they are each yielded and then discarded. But the disadvantage is that we parse the file to create the tracepoints for saving, then we parse it again to make the icon, then we parse it again to make the picture.</p>
<p>I don't have a feel for which approach (parse once vs parse many times) would be preferred so I'm seeking other input.</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/openstreetmap/openstreetmap-website/issues/2133">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ABWnLcdYffViIWv5YxoxKHWSqk6BpDPsks5vKquGgaJpZM4ak6yZ">mute the thread</a>.<img src="https://github.com/notifications/beacon/ABWnLY1cI37vb8tJ18S15nELzUe8mw4jks5vKquGgaJpZM4ak6yZ.gif" height="1" width="1" alt="" /></p>
<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/openstreetmap/openstreetmap-website","title":"openstreetmap/openstreetmap-website","subtitle":"GitHub repository","main_image_url":"https://github.githubassets.com/images/email/message_cards/header.png","avatar_image_url":"https://github.githubassets.com/images/email/message_cards/avatar.png","action":{"name":"Open in GitHub","url":"https://github.com/openstreetmap/openstreetmap-website"}},"updates":{"snippets":[{"icon":"DESCRIPTION","message":"Repeated XML parsing or storing points in memory in gpx.rb? (#2133)"}],"action":{"name":"View Issue","url":"https://github.com/openstreetmap/openstreetmap-website/issues/2133"}}}</script>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/openstreetmap/openstreetmap-website/issues/2133",
"url": "https://github.com/openstreetmap/openstreetmap-website/issues/2133",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>