{"action":"closed","issue":{"url":"https://api.github.com/repos/reedacartwright/dawg/issues/54","repository_url":"https://api.github.com/repos/reedacartwright/dawg","labels_url":"https://api.github.com/repos/reedacartwright/dawg/issues/54/labels{/name}","comments_url":"https://api.github.com/repos/reedacartwright/dawg/issues/54/comments","events_url":"https://api.github.com/repos/reedacartwright/dawg/issues/54/events","html_url":"https://github.com/reedacartwright/dawg/issues/54","id":322618652,"number":54,"title":"Different power of two algorithm","user":{"login":"zmertens","id":5597089,"avatar_url":"https://avatars3.githubusercontent.com/u/5597089?v=4","gravatar_id":"","url":"https://api.github.com/users/zmertens","html_url":"https://github.com/zmertens","followers_url":"https://api.github.com/users/zmertens/followers","following_url":"https://api.github.com/users/zmertens/following{/other_user}","gists_url":"https://api.github.com/users/zmertens/gists{/gist_id}","starred_url":"https://api.github.com/users/zmertens/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zmertens/subscriptions","organizations_url":"https://api.github.com/users/zmertens/orgs","repos_url":"https://api.github.com/users/zmertens/repos","events_url":"https://api.github.com/users/zmertens/events{/privacy}","received_events_url":"https://api.github.com/users/zmertens/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-05-13T19:02:40Z","updated_at":"2018-05-14T20:46:58Z","closed_at":"2018-05-14T20:46:58Z","author_association":"CONTRIBUTOR","body":"https://github.com/reedacartwright/dawg/blob/9c44bdc8cb1ebbfca4cddf4976841d734cf09288/src/include/dawg/utils/aliastable.h#L125-L131\r\n\r\nI came across this algorithm [here](http://bits.stephan-brumme.com/roundUpToNextPowerOfTwo.html), and it is non-iterative and appears to work very well for 32-bit numbers.\r\n```c++\r\ninline int nextPowerOfTwo(int x)\r\n{\r\n    --x;\r\n    x |= x >> 1; // handle 2 bit numbers\r\n    x |= x >> 2; // handle 4 bit numbers\r\n    x |= x >> 4; // handle 8 bit numbers\r\n    x |= x >> 8; // handle 16 bit numbers\r\n    x |= x >> 16; // handle 32 bit numbers\r\n    x++;\r\n    return x;\r\n}\r\n```\r\n\r\nI was wondering what you might think Reed and if it would be worth profiling it?"}}
{"actor":{"display_login":"zmertens"}}