{"action":"opened","issue":{"url":"https://api.github.com/repos/yandex/yoctodb/issues/28","repository_url":"https://api.github.com/repos/yandex/yoctodb","labels_url":"https://api.github.com/repos/yandex/yoctodb/issues/28/labels{/name}","comments_url":"https://api.github.com/repos/yandex/yoctodb/issues/28/comments","events_url":"https://api.github.com/repos/yandex/yoctodb/issues/28/events","html_url":"https://github.com/yandex/yoctodb/issues/28","id":154499378,"number":28,"title":"Optimize SimpleAndCondition.set()","user":{"login":"incubos","id":665821,"avatar_url":"https://avatars.githubusercontent.com/u/665821?v=3","gravatar_id":"","url":"https://api.github.com/users/incubos","html_url":"https://github.com/incubos","followers_url":"https://api.github.com/users/incubos/followers","following_url":"https://api.github.com/users/incubos/following{/other_user}","gists_url":"https://api.github.com/users/incubos/gists{/gist_id}","starred_url":"https://api.github.com/users/incubos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/incubos/subscriptions","organizations_url":"https://api.github.com/users/incubos/orgs","repos_url":"https://api.github.com/users/incubos/repos","events_url":"https://api.github.com/users/incubos/events{/privacy}","received_events_url":"https://api.github.com/users/incubos/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/yandex/yoctodb/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":{"login":"incubos","id":665821,"avatar_url":"https://avatars.githubusercontent.com/u/665821?v=3","gravatar_id":"","url":"https://api.github.com/users/incubos","html_url":"https://github.com/incubos","followers_url":"https://api.github.com/users/incubos/followers","following_url":"https://api.github.com/users/incubos/following{/other_user}","gists_url":"https://api.github.com/users/incubos/gists{/gist_id}","starred_url":"https://api.github.com/users/incubos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/incubos/subscriptions","organizations_url":"https://api.github.com/users/incubos/orgs","repos_url":"https://api.github.com/users/incubos/repos","events_url":"https://api.github.com/users/incubos/events{/privacy}","received_events_url":"https://api.github.com/users/incubos/received_events","type":"User","site_admin":false},"milestone":null,"comments":0,"created_at":"2016-05-12T14:39:24Z","updated_at":"2016-05-12T14:39:24Z","closed_at":null,"body":"The problem lies in premature allocation and `set`ting of `result` when we have >= 1 clauses.\r\nWe can do better with manual unrolling:\r\n\r\n1. Allocate `result`\r\n1. Apply `iter.next().set(result)`\r\n  * If `false` then return `false`\r\n1. Allocate `clauseResult`\r\n1. Then `do`\r\n  * Apply `iter.next().set(clauseResult)`\r\n  * If `false` then return `false`\r\n  * If `result.and(clauseResult)` is `false` then return `false`\r\n  * If `iter.hasNext()` then `clauseResult.clear()`\r\n  * `while (iter.hasNext())`"}}