{"action":"created","comment":{"url":"https://api.github.com/repos/zendframework/ZendSearch/pulls/comments/23010770","id":23010770,"diff_hunk":"@@ -87,7 +87,7 @@ public static function getPrefix($str, $length)\n                 }\n             }\n \n-            if ($prefixBytes + $charBytes > strlen($str)) {\n+            if(!isset($str[$prefixBytes+$charBytes-1])) {","path":"library/ZendSearch/Lucene/Index/Term.php","position":14,"original_position":14,"commit_id":"25d06fe70be9d06848b5da043e982aef43c92913","original_commit_id":"25d06fe70be9d06848b5da043e982aef43c92913","user":{"login":"Ocramius","id":154256,"avatar_url":"https://avatars.githubusercontent.com/u/154256?v=3","gravatar_id":"","url":"https://api.github.com/users/Ocramius","html_url":"https://github.com/Ocramius","followers_url":"https://api.github.com/users/Ocramius/followers","following_url":"https://api.github.com/users/Ocramius/following{/other_user}","gists_url":"https://api.github.com/users/Ocramius/gists{/gist_id}","starred_url":"https://api.github.com/users/Ocramius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ocramius/subscriptions","organizations_url":"https://api.github.com/users/Ocramius/orgs","repos_url":"https://api.github.com/users/Ocramius/repos","events_url":"https://api.github.com/users/Ocramius/events{/privacy}","received_events_url":"https://api.github.com/users/Ocramius/received_events","type":"User","site_admin":false},"body":"Please fix CS here (PSR-2 should be preferred).\r\n\r\n`if (! isset($str[$prefixBytes + $charBytes - 1])) {`","created_at":"2015-01-15T14:05:35Z","updated_at":"2015-01-15T14:05:35Z","html_url":"https://github.com/zendframework/ZendSearch/pull/19#discussion_r23010770","pull_request_url":"https://api.github.com/repos/zendframework/ZendSearch/pulls/19","_links":{"self":{"href":"https://api.github.com/repos/zendframework/ZendSearch/pulls/comments/23010770"},"html":{"href":"https://github.com/zendframework/ZendSearch/pull/19#discussion_r23010770"},"pull_request":{"href":"https://api.github.com/repos/zendframework/ZendSearch/pulls/19"}}},"pull_request":{"url":"https://api.github.com/repos/zendframework/ZendSearch/pulls/19","id":27421914,"html_url":"https://github.com/zendframework/ZendSearch/pull/19","diff_url":"https://github.com/zendframework/ZendSearch/pull/19.diff","patch_url":"https://github.com/zendframework/ZendSearch/pull/19.patch","issue_url":"https://api.github.com/repos/zendframework/ZendSearch/issues/19","number":19,"state":"open","locked":false,"title":"Use isset() instead of strlen()","user":{"login":"LukasReschke","id":878997,"avatar_url":"https://avatars.githubusercontent.com/u/878997?v=3","gravatar_id":"","url":"https://api.github.com/users/LukasReschke","html_url":"https://github.com/LukasReschke","followers_url":"https://api.github.com/users/LukasReschke/followers","following_url":"https://api.github.com/users/LukasReschke/following{/other_user}","gists_url":"https://api.github.com/users/LukasReschke/gists{/gist_id}","starred_url":"https://api.github.com/users/LukasReschke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LukasReschke/subscriptions","organizations_url":"https://api.github.com/users/LukasReschke/orgs","repos_url":"https://api.github.com/users/LukasReschke/repos","events_url":"https://api.github.com/users/LukasReschke/events{/privacy}","received_events_url":"https://api.github.com/users/LukasReschke/received_events","type":"User","site_admin":false},"body":"`strlen()` is `O(n)` while `isset()` is `O(1)`. Thus this function was way too slow before and when called very often (e.g. 100k times with long string values) took more than one minute before for us at ownCloud.\r\n\r\nThis should make the function about 50% faster according to the blackfire.io profiler. (and also reduce the overall memory usage)\r\n\r\nA simple test script showed the following changes for me:\r\n\r\n![screen shot 2015-01-15 at 12 29 44](https://cloud.githubusercontent.com/assets/878997/5756655/394e9968-9cb2-11e4-8f17-709e137536d3.png)\r\n","created_at":"2015-01-15T11:30:16Z","updated_at":"2015-01-15T14:05:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a762748c5b3e3e9b621cef6fe058a77b9e59f780","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/zendframework/ZendSearch/pulls/19/commits","review_comments_url":"https://api.github.com/repos/zendframework/ZendSearch/pulls/19/comments","review_comment_url":"https://api.github.com/repos/zendframework/ZendSearch/pulls/comments/{number}","comments_url":"https://api.github.com/repos/zendframework/ZendSearch/issues/19/comments","statuses_url":"https://api.github.com/repos/zendframework/ZendSearch/statuses/25d06fe70be9d06848b5da043e982aef43c92913","head":{"label":"LukasReschke:replace-strlen","ref":"replace-strlen","sha":"25d06fe70be9d06848b5da043e982aef43c92913","user":{"login":"LukasReschke","id":878997,"avatar_url":"https://avatars.githubusercontent.com/u/878997?v=3","gravatar_id":"","url":"https://api.github.com/users/LukasReschke","html_url":"https://github.com/LukasReschke","followers_url":"https://api.github.com/users/LukasReschke/followers","following_url":"https://api.github.com/users/LukasReschke/following{/other_user}","gists_url":"https://api.github.com/users/LukasReschke/gists{/gist_id}","starred_url":"https://api.github.com/users/LukasReschke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LukasReschke/subscriptions","organizations_url":"https://api.github.com/users/LukasReschke/orgs","repos_url":"https://api.github.com/users/LukasReschke/repos","events_url":"https://api.github.com/users/LukasReschke/events{/privacy}","received_events_url":"https://api.github.com/users/LukasReschke/received_events","type":"User","site_admin":false},"repo":{"id":23394366,"name":"ZendSearch","full_name":"LukasReschke/ZendSearch","owner":{"login":"LukasReschke","id":878997,"avatar_url":"https://avatars.githubusercontent.com/u/878997?v=3","gravatar_id":"","url":"https://api.github.com/users/LukasReschke","html_url":"https://github.com/LukasReschke","followers_url":"https://api.github.com/users/LukasReschke/followers","following_url":"https://api.github.com/users/LukasReschke/following{/other_user}","gists_url":"https://api.github.com/users/LukasReschke/gists{/gist_id}","starred_url":"https://api.github.com/users/LukasReschke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LukasReschke/subscriptions","organizations_url":"https://api.github.com/users/LukasReschke/orgs","repos_url":"https://api.github.com/users/LukasReschke/repos","events_url":"https://api.github.com/users/LukasReschke/events{/privacy}","received_events_url":"https://api.github.com/users/LukasReschke/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/LukasReschke/ZendSearch","description":"","fork":true,"url":"https://api.github.com/repos/LukasReschke/ZendSearch","forks_url":"https://api.github.com/repos/LukasReschke/ZendSearch/forks","keys_url":"https://api.github.com/repos/LukasReschke/ZendSearch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/LukasReschke/ZendSearch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/LukasReschke/ZendSearch/teams","hooks_url":"https://api.github.com/repos/LukasReschke/ZendSearch/hooks","issue_events_url":"https://api.github.com/repos/LukasReschke/ZendSearch/issues/events{/number}","events_url":"https://api.github.com/repos/LukasReschke/ZendSearch/events","assignees_url":"https://api.github.com/repos/LukasReschke/ZendSearch/assignees{/user}","branches_url":"https://api.github.com/repos/LukasReschke/ZendSearch/branches{/branch}","tags_url":"https://api.github.com/repos/LukasReschke/ZendSearch/tags","blobs_url":"https://api.github.com/repos/LukasReschke/ZendSearch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/LukasReschke/ZendSearch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/LukasReschke/ZendSearch/git/refs{/sha}","trees_url":"https://api.github.com/repos/LukasReschke/ZendSearch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/LukasReschke/ZendSearch/statuses/{sha}","languages_url":"https://api.github.com/repos/LukasReschke/ZendSearch/languages","stargazers_url":"https://api.github.com/repos/LukasReschke/ZendSearch/stargazers","contributors_url":"https://api.github.com/repos/LukasReschke/ZendSearch/contributors","subscribers_url":"https://api.github.com/repos/LukasReschke/ZendSearch/subscribers","subscription_url":"https://api.github.com/repos/LukasReschke/ZendSearch/subscription","commits_url":"https://api.github.com/repos/LukasReschke/ZendSearch/commits{/sha}","git_commits_url":"https://api.github.com/repos/LukasReschke/ZendSearch/git/commits{/sha}","comments_url":"https://api.github.com/repos/LukasReschke/ZendSearch/comments{/number}","issue_comment_url":"https://api.github.com/repos/LukasReschke/ZendSearch/issues/comments/{number}","contents_url":"https://api.github.com/repos/LukasReschke/ZendSearch/contents/{+path}","compare_url":"https://api.github.com/repos/LukasReschke/ZendSearch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/LukasReschke/ZendSearch/merges","archive_url":"https://api.github.com/repos/LukasReschke/ZendSearch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/LukasReschke/ZendSearch/downloads","issues_url":"https://api.github.com/repos/LukasReschke/ZendSearch/issues{/number}","pulls_url":"https://api.github.com/repos/LukasReschke/ZendSearch/pulls{/number}","milestones_url":"https://api.github.com/repos/LukasReschke/ZendSearch/milestones{/number}","notifications_url":"https://api.github.com/repos/LukasReschke/ZendSearch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/LukasReschke/ZendSearch/labels{/name}","releases_url":"https://api.github.com/repos/LukasReschke/ZendSearch/releases{/id}","created_at":"2014-08-27T15:14:03Z","updated_at":"2014-07-26T15:57:41Z","pushed_at":"2015-01-15T11:29:18Z","git_url":"git://github.com/LukasReschke/ZendSearch.git","ssh_url":"git@github.com:LukasReschke/ZendSearch.git","clone_url":"https://github.com/LukasReschke/ZendSearch.git","svn_url":"https://github.com/LukasReschke/ZendSearch","homepage":null,"size":1275,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"zendframework:master","ref":"master","sha":"cd06d485eb679f112f9e2fceb7d4480b9b8c2816","user":{"login":"zendframework","id":296074,"avatar_url":"https://avatars.githubusercontent.com/u/296074?v=3","gravatar_id":"","url":"https://api.github.com/users/zendframework","html_url":"https://github.com/zendframework","followers_url":"https://api.github.com/users/zendframework/followers","following_url":"https://api.github.com/users/zendframework/following{/other_user}","gists_url":"https://api.github.com/users/zendframework/gists{/gist_id}","starred_url":"https://api.github.com/users/zendframework/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zendframework/subscriptions","organizations_url":"https://api.github.com/users/zendframework/orgs","repos_url":"https://api.github.com/users/zendframework/repos","events_url":"https://api.github.com/users/zendframework/events{/privacy}","received_events_url":"https://api.github.com/users/zendframework/received_events","type":"Organization","site_admin":false},"repo":{"id":5128017,"name":"ZendSearch","full_name":"zendframework/ZendSearch","owner":{"login":"zendframework","id":296074,"avatar_url":"https://avatars.githubusercontent.com/u/296074?v=3","gravatar_id":"","url":"https://api.github.com/users/zendframework","html_url":"https://github.com/zendframework","followers_url":"https://api.github.com/users/zendframework/followers","following_url":"https://api.github.com/users/zendframework/following{/other_user}","gists_url":"https://api.github.com/users/zendframework/gists{/gist_id}","starred_url":"https://api.github.com/users/zendframework/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zendframework/subscriptions","organizations_url":"https://api.github.com/users/zendframework/orgs","repos_url":"https://api.github.com/users/zendframework/repos","events_url":"https://api.github.com/users/zendframework/events{/privacy}","received_events_url":"https://api.github.com/users/zendframework/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/zendframework/ZendSearch","description":"","fork":false,"url":"https://api.github.com/repos/zendframework/ZendSearch","forks_url":"https://api.github.com/repos/zendframework/ZendSearch/forks","keys_url":"https://api.github.com/repos/zendframework/ZendSearch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zendframework/ZendSearch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zendframework/ZendSearch/teams","hooks_url":"https://api.github.com/repos/zendframework/ZendSearch/hooks","issue_events_url":"https://api.github.com/repos/zendframework/ZendSearch/issues/events{/number}","events_url":"https://api.github.com/repos/zendframework/ZendSearch/events","assignees_url":"https://api.github.com/repos/zendframework/ZendSearch/assignees{/user}","branches_url":"https://api.github.com/repos/zendframework/ZendSearch/branches{/branch}","tags_url":"https://api.github.com/repos/zendframework/ZendSearch/tags","blobs_url":"https://api.github.com/repos/zendframework/ZendSearch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zendframework/ZendSearch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zendframework/ZendSearch/git/refs{/sha}","trees_url":"https://api.github.com/repos/zendframework/ZendSearch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zendframework/ZendSearch/statuses/{sha}","languages_url":"https://api.github.com/repos/zendframework/ZendSearch/languages","stargazers_url":"https://api.github.com/repos/zendframework/ZendSearch/stargazers","contributors_url":"https://api.github.com/repos/zendframework/ZendSearch/contributors","subscribers_url":"https://api.github.com/repos/zendframework/ZendSearch/subscribers","subscription_url":"https://api.github.com/repos/zendframework/ZendSearch/subscription","commits_url":"https://api.github.com/repos/zendframework/ZendSearch/commits{/sha}","git_commits_url":"https://api.github.com/repos/zendframework/ZendSearch/git/commits{/sha}","comments_url":"https://api.github.com/repos/zendframework/ZendSearch/comments{/number}","issue_comment_url":"https://api.github.com/repos/zendframework/ZendSearch/issues/comments/{number}","contents_url":"https://api.github.com/repos/zendframework/ZendSearch/contents/{+path}","compare_url":"https://api.github.com/repos/zendframework/ZendSearch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zendframework/ZendSearch/merges","archive_url":"https://api.github.com/repos/zendframework/ZendSearch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zendframework/ZendSearch/downloads","issues_url":"https://api.github.com/repos/zendframework/ZendSearch/issues{/number}","pulls_url":"https://api.github.com/repos/zendframework/ZendSearch/pulls{/number}","milestones_url":"https://api.github.com/repos/zendframework/ZendSearch/milestones{/number}","notifications_url":"https://api.github.com/repos/zendframework/ZendSearch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zendframework/ZendSearch/labels{/name}","releases_url":"https://api.github.com/repos/zendframework/ZendSearch/releases{/id}","created_at":"2012-07-20T20:31:47Z","updated_at":"2014-12-28T05:08:46Z","pushed_at":"2014-02-15T15:17:10Z","git_url":"git://github.com/zendframework/ZendSearch.git","ssh_url":"git@github.com:zendframework/ZendSearch.git","clone_url":"https://github.com/zendframework/ZendSearch.git","svn_url":"https://github.com/zendframework/ZendSearch","homepage":null,"size":1477,"stargazers_count":38,"watchers_count":38,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":38,"mirror_url":null,"open_issues_count":11,"forks":38,"open_issues":11,"watchers":38,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/zendframework/ZendSearch/pulls/19"},"html":{"href":"https://github.com/zendframework/ZendSearch/pull/19"},"issue":{"href":"https://api.github.com/repos/zendframework/ZendSearch/issues/19"},"comments":{"href":"https://api.github.com/repos/zendframework/ZendSearch/issues/19/comments"},"review_comments":{"href":"https://api.github.com/repos/zendframework/ZendSearch/pulls/19/comments"},"review_comment":{"href":"https://api.github.com/repos/zendframework/ZendSearch/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/zendframework/ZendSearch/pulls/19/commits"},"statuses":{"href":"https://api.github.com/repos/zendframework/ZendSearch/statuses/25d06fe70be9d06848b5da043e982aef43c92913"}}}}