{"action":"created","issue":{"url":"https://api.github.com/repos/keepassxreboot/keepassxc/issues/2443","repository_url":"https://api.github.com/repos/keepassxreboot/keepassxc","labels_url":"https://api.github.com/repos/keepassxreboot/keepassxc/issues/2443/labels{/name}","comments_url":"https://api.github.com/repos/keepassxreboot/keepassxc/issues/2443/comments","events_url":"https://api.github.com/repos/keepassxreboot/keepassxc/issues/2443/events","html_url":"https://github.com/keepassxreboot/keepassxc/pull/2443","id":376107419,"node_id":"MDExOlB1bGxSZXF1ZXN0MjI3NDAwMzk5","number":2443,"title":"Code cleanup and performance improvements - Part 2","user":{"login":"brainplot","id":28014843,"node_id":"MDQ6VXNlcjI4MDE0ODQz","avatar_url":"https://avatars2.githubusercontent.com/u/28014843?v=4","gravatar_id":"","url":"https://api.github.com/users/brainplot","html_url":"https://github.com/brainplot","followers_url":"https://api.github.com/users/brainplot/followers","following_url":"https://api.github.com/users/brainplot/following{/other_user}","gists_url":"https://api.github.com/users/brainplot/gists{/gist_id}","starred_url":"https://api.github.com/users/brainplot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brainplot/subscriptions","organizations_url":"https://api.github.com/users/brainplot/orgs","repos_url":"https://api.github.com/users/brainplot/repos","events_url":"https://api.github.com/users/brainplot/events{/privacy}","received_events_url":"https://api.github.com/users/brainplot/received_events","type":"User","site_admin":false},"labels":[{"id":863073457,"node_id":"MDU6TGFiZWw4NjMwNzM0NTc=","url":"https://api.github.com/repos/keepassxreboot/keepassxc/labels/PR:%20Ready%20for%20Merge","name":"PR: Ready for Merge","color":"7aefb8","default":false},{"id":1069446761,"node_id":"MDU6TGFiZWwxMDY5NDQ2NzYx","url":"https://api.github.com/repos/keepassxreboot/keepassxc/labels/refactor","name":"refactor","color":"e0b160","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/keepassxreboot/keepassxc/milestones/12","html_url":"https://github.com/keepassxreboot/keepassxc/milestone/12","labels_url":"https://api.github.com/repos/keepassxreboot/keepassxc/milestones/12/labels","id":2937739,"node_id":"MDk6TWlsZXN0b25lMjkzNzczOQ==","number":12,"title":"v2.4.0","description":"Another major feature release; currently setting up the backlog.","creator":{"login":"droidmonkey","id":2809491,"node_id":"MDQ6VXNlcjI4MDk0OTE=","avatar_url":"https://avatars2.githubusercontent.com/u/2809491?v=4","gravatar_id":"","url":"https://api.github.com/users/droidmonkey","html_url":"https://github.com/droidmonkey","followers_url":"https://api.github.com/users/droidmonkey/followers","following_url":"https://api.github.com/users/droidmonkey/following{/other_user}","gists_url":"https://api.github.com/users/droidmonkey/gists{/gist_id}","starred_url":"https://api.github.com/users/droidmonkey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/droidmonkey/subscriptions","organizations_url":"https://api.github.com/users/droidmonkey/orgs","repos_url":"https://api.github.com/users/droidmonkey/repos","events_url":"https://api.github.com/users/droidmonkey/events{/privacy}","received_events_url":"https://api.github.com/users/droidmonkey/received_events","type":"User","site_admin":false},"open_issues":100,"closed_issues":103,"state":"open","created_at":"2017-11-26T22:05:08Z","updated_at":"2018-11-24T23:44:56Z","due_on":null,"closed_at":null},"comments":16,"created_at":"2018-10-31T18:39:57Z","updated_at":"2018-11-25T20:11:10Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/keepassxreboot/keepassxc/pulls/2443","html_url":"https://github.com/keepassxreboot/keepassxc/pull/2443","diff_url":"https://github.com/keepassxreboot/keepassxc/pull/2443.diff","patch_url":"https://github.com/keepassxreboot/keepassxc/pull/2443.patch"},"body":"I found a few more issues after a more thorough inspection of Clazy, that was disabled by default.\r\n\r\n## Description\r\n* **Avoid allocating temporary containers**\r\nCalling `toLower()` on a `QString` will cause a new string to be allocated. Since the function is essentially invoked to perform a case-insensitive comparison, we can invoke the `contains()` method with the `Qt::CaseInsensitive` enum value to do just that, as opposed to calling `toLower()` on two different strings.\r\n\r\n* **Remove unused variables**\r\nFor some reason there were completely unused variables in the code. One of them was even initialized with the result of a method, but never used nonetheless (maybe it was the source of a bug).\r\n\r\n* **Use `QVariant::toUrl()` instead of `QVariant::value<QUrl>()`**\r\nThe analyzer was suggesting me to do this. I guess the latter is more performant since it's not a template :thinking:\r\n\r\n* **Fix typo in parameter name**\r\nThis is a very minor thing. There was a typo in the declaration of a function (`erroMessage` instead of `errorMessage`), which was spelt correctly in the definition of the same function, and the analyzer reported the inconsistency between the two.\r\n\r\n* **Improve type-safety**\r\nSome zeros used to initialize a pointer were left out of my previous commit. I think they were introduced with the PR which adds more expiration presets.\r\n\r\n## How has this been tested?\r\nCompiled with all tests enabled (GUI tests included) and `-DWITH_DEV_BUILD` on and all tests passed.\r\n\r\n## Types of changes\r\n- ✅ Bug fix (non-breaking change which fixes an issue)\r\n\r\n## Checklist:\r\n- ✅ I have read the **CONTRIBUTING** document. **[REQUIRED]**\r\n- ✅ My code follows the code style of this project. **[REQUIRED]**\r\n- ✅ All new and existing tests passed. **[REQUIRED]**\r\n- ✅ I have compiled and verified my code with `-DWITH_ASAN=ON`. **[REQUIRED]**\r\n"},"comment":{"url":"https://api.github.com/repos/keepassxreboot/keepassxc/issues/comments/441468947","html_url":"https://github.com/keepassxreboot/keepassxc/pull/2443#issuecomment-441468947","issue_url":"https://api.github.com/repos/keepassxreboot/keepassxc/issues/2443","id":441468947,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0MTQ2ODk0Nw==","user":{"login":"brainplot","id":28014843,"node_id":"MDQ6VXNlcjI4MDE0ODQz","avatar_url":"https://avatars2.githubusercontent.com/u/28014843?v=4","gravatar_id":"","url":"https://api.github.com/users/brainplot","html_url":"https://github.com/brainplot","followers_url":"https://api.github.com/users/brainplot/followers","following_url":"https://api.github.com/users/brainplot/following{/other_user}","gists_url":"https://api.github.com/users/brainplot/gists{/gist_id}","starred_url":"https://api.github.com/users/brainplot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brainplot/subscriptions","organizations_url":"https://api.github.com/users/brainplot/orgs","repos_url":"https://api.github.com/users/brainplot/repos","events_url":"https://api.github.com/users/brainplot/events{/privacy}","received_events_url":"https://api.github.com/users/brainplot/received_events","type":"User","site_admin":false},"created_at":"2018-11-25T20:11:10Z","updated_at":"2018-11-25T20:11:10Z","author_association":"CONTRIBUTOR","body":"Alright, this one was a little tricky to rebase because there was a good bunch of conflicts to deal with; but I managed it to do it correctly, I believe, since I ran all the tests and they all passed.\r\n\r\nI made one more change at the end: there was a variable declared in the `.cpp` file without being enclosed in any scope. Moreover, it was only used in a single function. I moved it into the function it was used it and made it `static` so that it gets initialized only once and not every time the function is invoked.\r\n```diff\r\n-// Escape common regex symbols except for *, ?, and |\r\n-auto regexEscape = QRegularExpression(R\"re(([-[\\]{}()+.,\\\\\\/^$#]))re\");\r\n-\r\n QRegularExpression convertToRegex(const QString& string, bool useWildcards, bool exactMatch, bool caseSensitive)\r\n {\r\n     QString pattern = string;\r\n\r\n+    // Escape common regex symbols except for *, ?, and |\r\n+    static auto regexEscape = QRegularExpression(R\"re(([-[\\]{}()+.,\\\\\\/^$#]))re\");\r\n+\r\n     // Wildcard support (*, ?, |)\r\n     if (useWildcards) {\r\n         pattern.replace(regexEscape, \"\\\\\\\\1\");\r\n         pattern.replace(\"*\", \".*\");\r\n         pattern.replace(\"?\", \".\");\r\n     }\r\n\r\n     // Exact modifier\r\n     if (exactMatch) {\r\n         pattern = \"^\" + pattern + \"$\";\r\n     }\r\n\r\n     auto regex = QRegularExpression(pattern);\r\n     if (!caseSensitive) {\r\n         regex.setPatternOptions(QRegularExpression::CaseInsensitiveOption);\r\n     }\r\n\r\n     return regex;\r\n }\r\n```"}}
{"actor":{"display_login":"brainplot"}}