{"action":"created","issue":{"url":"https://api.github.com/repos/espruino/Espruino/issues/467","labels_url":"https://api.github.com/repos/espruino/Espruino/issues/467/labels{/name}","comments_url":"https://api.github.com/repos/espruino/Espruino/issues/467/comments","events_url":"https://api.github.com/repos/espruino/Espruino/issues/467/events","html_url":"https://github.com/espruino/Espruino/issues/467","id":52245461,"number":467,"title":"Intelligent use of 'flat strings'","user":{"login":"gfwilliams","id":754445,"avatar_url":"https://avatars.githubusercontent.com/u/754445?v=3","gravatar_id":"","url":"https://api.github.com/users/gfwilliams","html_url":"https://github.com/gfwilliams","followers_url":"https://api.github.com/users/gfwilliams/followers","following_url":"https://api.github.com/users/gfwilliams/following{/other_user}","gists_url":"https://api.github.com/users/gfwilliams/gists{/gist_id}","starred_url":"https://api.github.com/users/gfwilliams/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gfwilliams/subscriptions","organizations_url":"https://api.github.com/users/gfwilliams/orgs","repos_url":"https://api.github.com/users/gfwilliams/repos","events_url":"https://api.github.com/users/gfwilliams/events{/privacy}","received_events_url":"https://api.github.com/users/gfwilliams/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/espruino/Espruino/labels/enhancement","name":"enhancement","color":"84b6eb"},{"url":"https://api.github.com/repos/espruino/Espruino/labels/optimisation","name":"optimisation","color":"009800"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2014-12-17T14:26:10Z","updated_at":"2015-11-03T18:50:09Z","closed_at":null,"body":"So I just added this: 14f987bcb5d348421080a6a77041730df96549b1\r\n\r\nIt allows strings to be allocated as continuous chunks of memory (at the expense of a bit of allocation speed), which makes big ones much faster to access. It also uses memory more efficiently and speeds up garbage collection.\r\n\r\nI've just used it for typed arrays, where it makes a great difference on anything that accesses a big array without using forEach/map/etc. Even arraybuffer graphics should be much improved.\r\n\r\nHowever this could also be used for other things - big strings and also function code. I wouldn't want to use it all the time as it takes longer to allocate though. It'd be good to get some nice simple heuristics:\r\n\r\n* When defining a function a root scope\r\n* **Not** when defining a function from within another function - this would hurt stuff like `setTimeout`\r\n* When creating a big string - the only examples I can think of this right now are `btoa`/`atob`\r\n"},"comment":{"url":"https://api.github.com/repos/espruino/Espruino/issues/comments/153451874","html_url":"https://github.com/espruino/Espruino/issues/467#issuecomment-153451874","issue_url":"https://api.github.com/repos/espruino/Espruino/issues/467","id":153451874,"user":{"login":"gfwilliams","id":754445,"avatar_url":"https://avatars.githubusercontent.com/u/754445?v=3","gravatar_id":"","url":"https://api.github.com/users/gfwilliams","html_url":"https://github.com/gfwilliams","followers_url":"https://api.github.com/users/gfwilliams/followers","following_url":"https://api.github.com/users/gfwilliams/following{/other_user}","gists_url":"https://api.github.com/users/gfwilliams/gists{/gist_id}","starred_url":"https://api.github.com/users/gfwilliams/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gfwilliams/subscriptions","organizations_url":"https://api.github.com/users/gfwilliams/orgs","repos_url":"https://api.github.com/users/gfwilliams/repos","events_url":"https://api.github.com/users/gfwilliams/events{/privacy}","received_events_url":"https://api.github.com/users/gfwilliams/received_events","type":"User","site_admin":false},"created_at":"2015-11-03T18:50:09Z","updated_at":"2015-11-03T18:50:09Z","body":"Ok, just committed something that makes *all* functions use flat strings, unless they're so small it doesn't matter. It'll be interesting to see if it actually affects performance - it should increase execution speed and use less memory, but then the process of creating a new function will be marginally slower too."}}