Title: Performance & Code Style, avoid passing iterators around · Issue #340 · stleary/JSON-java · GitHub
Open Graph Title: Performance & Code Style, avoid passing iterators around · Issue #340 · stleary/JSON-java
X Title: Performance & Code Style, avoid passing iterators around · Issue #340 · stleary/JSON-java
Description: Hi, I have an issue with the JSONObjecy#keys() method. It states it is an iterator, though the name implies it is an access to a collection. I have also noticed that is it used often in a while(iter.hasNext){foo = iter.next; ...) pattern...
Open Graph Description: Hi, I have an issue with the JSONObjecy#keys() method. It states it is an iterator, though the name implies it is an access to a collection. I have also noticed that is it used often in a while(ite...
X Description: Hi, I have an issue with the JSONObjecy#keys() method. It states it is an iterator, though the name implies it is an access to a collection. I have also noticed that is it used often in a while(ite...
Opengraph URL: https://github.com/stleary/JSON-java/issues/340
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Performance & Code Style, avoid passing iterators around","articleBody":"Hi,\r\nI have an issue with the JSONObjecy#keys() method. It states it is an iterator, though the name implies it is an access to a collection. I have also noticed that is it used often in a while(iter.hasNext){foo = iter.next; ...) pattern. This is not as optimal as using an enhanced for loop on a JSONObject#keySet(). It is murky as to whether or not I am allowed to contribute code yet, but if you replace all #keys accesses by #keyset for loops you can go from parsing a 2 GB file in 125 seconds to 115. this is not an order of magnitude like @johnjaylward 's #337 patch, but it's still pretty decent.\r\n\r\nOne could argue the reason for doing the iterator is to avoid issues with concurrent modifications. I would argue that a readwritelock would be a safer approach in general.\r\n\r\nThanks for making such a great product by the way.","author":{"url":"https://github.com/TheMatthew","@type":"Person","name":"TheMatthew"},"datePublished":"2017-05-22T01:16:51Z","url":"https://github.com/stleary/JSON-java/issues/340"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:f210a8ff-457e-7025-fd15-45f0135e663a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AF8C:5A20F:98F77:DB17D:6AFD58DE |
| html-safe-nonce | eb9f8d914b7ce86d733c8bf5aa9d4ce821c4ed0d51af1efda054a64697f0798f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRjhDOjVBMjBGOjk4Rjc3OkRCMTdEOjZBRkQ1OERFIiwidmlzaXRvcl9pZCI6IjQzNTczMjAxNTEyMzQ1OTkxMzQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 4cb6b08bc2cf8f5dc366f24e2bfce198bd8ee05284214a819a01de4d1da43d78 |
| hovercard-subject-tag | issue:230263075 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/stleary/JSON-java/340/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3d21ae862b1dd1cad5787dcc4fa4ac433c01892864c81a4eceb3b4365d7bd4e7/stleary/JSON-java/issues/340 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3d21ae862b1dd1cad5787dcc4fa4ac433c01892864c81a4eceb3b4365d7bd4e7/stleary/JSON-java/issues/340 |
| og:image:alt | Hi, I have an issue with the JSONObjecy#keys() method. It states it is an iterator, though the name implies it is an access to a collection. I have also noticed that is it used often in a while(ite... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | TheMatthew |
| hostname | github.com |
| expected-hostname | github.com |
| None | 66653c2e55a6fff2930be1bdf07ee4f8aa137e3956d056c822563be6f878755e |
| turbo-cache-control | no-preview |
| go-import | github.com/stleary/JSON-java git https://github.com/stleary/JSON-java.git |
| octolytics-dimension-user_id | 5107558 |
| octolytics-dimension-user_login | stleary |
| octolytics-dimension-repository_id | 1187853 |
| octolytics-dimension-repository_nwo | stleary/JSON-java |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1187853 |
| octolytics-dimension-repository_network_root_nwo | stleary/JSON-java |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | b6f01f7cb9f35f8c09949773241a3d49dd04b340 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width