{"action":"created","issue":{"url":"https://api.github.com/repos/samaaron/sonic-pi/issues/755","labels_url":"https://api.github.com/repos/samaaron/sonic-pi/issues/755/labels{/name}","comments_url":"https://api.github.com/repos/samaaron/sonic-pi/issues/755/comments","events_url":"https://api.github.com/repos/samaaron/sonic-pi/issues/755/events","html_url":"https://github.com/samaaron/sonic-pi/pull/755","id":113196701,"number":755,"title":"Remove string length hack during packing","user":{"login":"madgen","id":3607546,"avatar_url":"https://avatars.githubusercontent.com/u/3607546?v=3","gravatar_id":"","url":"https://api.github.com/users/madgen","html_url":"https://github.com/madgen","followers_url":"https://api.github.com/users/madgen/followers","following_url":"https://api.github.com/users/madgen/following{/other_user}","gists_url":"https://api.github.com/users/madgen/gists{/gist_id}","starred_url":"https://api.github.com/users/madgen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/madgen/subscriptions","organizations_url":"https://api.github.com/users/madgen/orgs","repos_url":"https://api.github.com/users/madgen/repos","events_url":"https://api.github.com/users/madgen/events{/privacy}","received_events_url":"https://api.github.com/users/madgen/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-10-25T00:27:51Z","updated_at":"2015-10-25T09:42:22Z","closed_at":"2015-10-25T09:41:37Z","pull_request":{"url":"https://api.github.com/repos/samaaron/sonic-pi/pulls/755","html_url":"https://github.com/samaaron/sonic-pi/pull/755","diff_url":"https://github.com/samaaron/sonic-pi/pull/755.diff","patch_url":"https://github.com/samaaron/sonic-pi/pull/755.patch"},"body":"Floating point operation is unnecessarily slow and is hacky in this\r\ncontext. This version produces the same output for each size while\r\nbeing faster.\r\n\r\nApproach with caution. Although it should behave the same, I tested\r\nonly by `rake test`.\r\n\r\nAs for the speed of the calculation:\r\n```ruby\r\nsizes = (0...1000).map {|el| rand}\r\n10000000.times { sizes << rand(10000) }\r\n\r\nBenchmark.bm do |x|\r\n  x.report(\"Bit manipulation\") do\r\n    sizes.each do |size|\r\n      size + 4 - (size % 4)\r\n    end\r\n  end\r\n\r\n  x.report(\"Floating point  \") do\r\n    sizes.each do |size|\r\n      4*((size.to_f+0.01)/4).ceil\r\n    end\r\n  end\r\nend\r\n\r\n#        user     system      total        real\r\n# Bit manipulation  0.770000   0.000000   0.770000 (  0.779492)\r\n# Floating point    1.750000   0.000000   1.750000 (  1.761073)\r\n```"},"comment":{"url":"https://api.github.com/repos/samaaron/sonic-pi/issues/comments/150905459","html_url":"https://github.com/samaaron/sonic-pi/pull/755#issuecomment-150905459","issue_url":"https://api.github.com/repos/samaaron/sonic-pi/issues/755","id":150905459,"user":{"login":"samaaron","id":369,"avatar_url":"https://avatars.githubusercontent.com/u/369?v=3","gravatar_id":"","url":"https://api.github.com/users/samaaron","html_url":"https://github.com/samaaron","followers_url":"https://api.github.com/users/samaaron/followers","following_url":"https://api.github.com/users/samaaron/following{/other_user}","gists_url":"https://api.github.com/users/samaaron/gists{/gist_id}","starred_url":"https://api.github.com/users/samaaron/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samaaron/subscriptions","organizations_url":"https://api.github.com/users/samaaron/orgs","repos_url":"https://api.github.com/users/samaaron/repos","events_url":"https://api.github.com/users/samaaron/events{/privacy}","received_events_url":"https://api.github.com/users/samaaron/received_events","type":"User","site_admin":false},"created_at":"2015-10-25T09:42:22Z","updated_at":"2015-10-25T09:42:22Z","body":"Thanks so much for this - looks much cleaner than the floating point hack. \r\n\r\n@xavriley do you have any comment (as this was your speed hack which improved over the previous implementation)."}}