{"action":"created","issue":{"url":"https://api.github.com/repos/baylej/tmx/issues/8","labels_url":"https://api.github.com/repos/baylej/tmx/issues/8/labels{/name}","comments_url":"https://api.github.com/repos/baylej/tmx/issues/8/comments","events_url":"https://api.github.com/repos/baylej/tmx/issues/8/events","html_url":"https://github.com/baylej/tmx/issues/8","id":78145161,"number":8,"title":"tmx_tile has an inefficient storage method (linked list)","user":{"login":"baylej","id":3799637,"avatar_url":"https://avatars.githubusercontent.com/u/3799637?v=3","gravatar_id":"","url":"https://api.github.com/users/baylej","html_url":"https://github.com/baylej","followers_url":"https://api.github.com/users/baylej/followers","following_url":"https://api.github.com/users/baylej/following{/other_user}","gists_url":"https://api.github.com/users/baylej/gists{/gist_id}","starred_url":"https://api.github.com/users/baylej/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/baylej/subscriptions","organizations_url":"https://api.github.com/users/baylej/orgs","repos_url":"https://api.github.com/users/baylej/repos","events_url":"https://api.github.com/users/baylej/events{/privacy}","received_events_url":"https://api.github.com/users/baylej/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/baylej/tmx/labels/feature","name":"feature","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-05-19T15:54:53Z","updated_at":"2015-07-15T15:13:23Z","closed_at":null,"body":"A linked list is inefficient here because we need random access to a given tile.\r\n\r\nTwo propositions:\r\n\r\n→ **Array**, random access,\r\nPros: easy to implement.\r\nCons: large memory footprint with a lot of tiles and a few `tmx_tile` to store.\r\n\r\n→ **Hashtable** using the tile `gid` as the key, linked-list for collisions, almost random access,\r\nPros: little memory footprint for sparse data.\r\nCons: cumbersome to implement.\r\n\r\nTiled uses a `QList` (array based) to store instances of `Tile`.\r\n\r\nI personally prefer the array, to keep the code simple."},"comment":{"url":"https://api.github.com/repos/baylej/tmx/issues/comments/121647335","html_url":"https://github.com/baylej/tmx/issues/8#issuecomment-121647335","issue_url":"https://api.github.com/repos/baylej/tmx/issues/8","id":121647335,"user":{"login":"RPGHacker","id":5788868,"avatar_url":"https://avatars.githubusercontent.com/u/5788868?v=3","gravatar_id":"","url":"https://api.github.com/users/RPGHacker","html_url":"https://github.com/RPGHacker","followers_url":"https://api.github.com/users/RPGHacker/followers","following_url":"https://api.github.com/users/RPGHacker/following{/other_user}","gists_url":"https://api.github.com/users/RPGHacker/gists{/gist_id}","starred_url":"https://api.github.com/users/RPGHacker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RPGHacker/subscriptions","organizations_url":"https://api.github.com/users/RPGHacker/orgs","repos_url":"https://api.github.com/users/RPGHacker/repos","events_url":"https://api.github.com/users/RPGHacker/events{/privacy}","received_events_url":"https://api.github.com/users/RPGHacker/received_events","type":"User","site_admin":false},"created_at":"2015-07-15T15:13:23Z","updated_at":"2015-07-15T15:13:23Z","body":"Nah, why would I hate you for this? ;)\r\nJust wanted to get a status update and some criticism to know what I can improve. I agree with everything you said, it would probably be faster in most (if not all) cases to just insert the tiles unsorted in the array (less moving around of memory during map construction) and then sort everything at the end. There are a few occassions when the map loader actually searches for tiles in the array during map construction (in the JSON version), that is why I decided to make it a sorted array. Though this is probably still slower than not sorting the elements and iterating over the array during map construction, so I acknowledge your suggestion."}}