{"action":"created","issue":{"url":"https://api.github.com/repos/official-stockfish/Stockfish/issues/313","labels_url":"https://api.github.com/repos/official-stockfish/Stockfish/issues/313/labels{/name}","comments_url":"https://api.github.com/repos/official-stockfish/Stockfish/issues/313/comments","events_url":"https://api.github.com/repos/official-stockfish/Stockfish/issues/313/events","html_url":"https://github.com/official-stockfish/Stockfish/pull/313","id":64681261,"number":313,"title":"Dumb down some incomprehensible code","user":{"login":"lucasart","id":2278294,"avatar_url":"https://avatars.githubusercontent.com/u/2278294?v=3","gravatar_id":"","url":"https://api.github.com/users/lucasart","html_url":"https://github.com/lucasart","followers_url":"https://api.github.com/users/lucasart/followers","following_url":"https://api.github.com/users/lucasart/following{/other_user}","gists_url":"https://api.github.com/users/lucasart/gists{/gist_id}","starred_url":"https://api.github.com/users/lucasart/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lucasart/subscriptions","organizations_url":"https://api.github.com/users/lucasart/orgs","repos_url":"https://api.github.com/users/lucasart/repos","events_url":"https://api.github.com/users/lucasart/events{/privacy}","received_events_url":"https://api.github.com/users/lucasart/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":13,"created_at":"2015-03-27T03:08:25Z","updated_at":"2015-03-29T16:48:19Z","closed_at":"2015-03-29T07:42:13Z","pull_request":{"url":"https://api.github.com/repos/official-stockfish/Stockfish/pulls/313","html_url":"https://github.com/official-stockfish/Stockfish/pull/313","diff_url":"https://github.com/official-stockfish/Stockfish/pull/313.diff","patch_url":"https://github.com/official-stockfish/Stockfish/pull/313.patch"},"body":"Code like this is more a case of showing off one's C++ knowledge, rather than\r\nusing it adequately, IMHO.\r\n\r\n**First loop (std::generate)**\r\n\r\nIterators are inadequate here, because they lose the key information which is\r\nidx. As a result, we need to carry a redundant idx variable, and increment it\r\nalong the way. Very clumsy.\r\nUsage of std::generate and a lambda function only obfuscate the code, which is\r\nmerely a simple and stupid loop over the elements of a vector.\r\n\r\n**Second loop (std::accumulate)**\r\n\r\nThis code is thoroughlly incomprehensible. Restore the original, which was much\r\nsimpler to understand.\r\n\r\n**Third loop (range based loop)**\r\n\r\nAgain, a range based loop is inadequate, because we lose idx! To resolve this\r\nartificially created problem, the data model was made redundant (idx is a data\r\nmember of db[] elements!?), which is ugly and unjustified. A simple and stupid\r\nfor loop with idx does the job much better.\r\n\r\nNo functional change."},"comment":{"url":"https://api.github.com/repos/official-stockfish/Stockfish/issues/comments/87442144","html_url":"https://github.com/official-stockfish/Stockfish/pull/313#issuecomment-87442144","issue_url":"https://api.github.com/repos/official-stockfish/Stockfish/issues/313","id":87442144,"user":{"login":"Altorffer","id":10152138,"avatar_url":"https://avatars.githubusercontent.com/u/10152138?v=3","gravatar_id":"","url":"https://api.github.com/users/Altorffer","html_url":"https://github.com/Altorffer","followers_url":"https://api.github.com/users/Altorffer/followers","following_url":"https://api.github.com/users/Altorffer/following{/other_user}","gists_url":"https://api.github.com/users/Altorffer/gists{/gist_id}","starred_url":"https://api.github.com/users/Altorffer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Altorffer/subscriptions","organizations_url":"https://api.github.com/users/Altorffer/orgs","repos_url":"https://api.github.com/users/Altorffer/repos","events_url":"https://api.github.com/users/Altorffer/events{/privacy}","received_events_url":"https://api.github.com/users/Altorffer/received_events","type":"User","site_admin":false},"created_at":"2015-03-29T16:48:19Z","updated_at":"2015-03-29T16:48:19Z","body":"Ah. Thanks for clarifying that."}}