{"action":"opened","number":15847,"pull_request":{"url":"https://api.github.com/repos/symfony/symfony/pulls/15847","id":45504649,"html_url":"https://github.com/symfony/symfony/pull/15847","diff_url":"https://github.com/symfony/symfony/pull/15847.diff","patch_url":"https://github.com/symfony/symfony/pull/15847.patch","issue_url":"https://api.github.com/repos/symfony/symfony/issues/15847","number":15847,"state":"open","locked":false,"title":"[DomCrawler] Optimize the regex used to find namespace prefixes","user":{"login":"stof","id":439401,"avatar_url":"https://avatars.githubusercontent.com/u/439401?v=3","gravatar_id":"","url":"https://api.github.com/users/stof","html_url":"https://github.com/stof","followers_url":"https://api.github.com/users/stof/followers","following_url":"https://api.github.com/users/stof/following{/other_user}","gists_url":"https://api.github.com/users/stof/gists{/gist_id}","starred_url":"https://api.github.com/users/stof/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stof/subscriptions","organizations_url":"https://api.github.com/users/stof/orgs","repos_url":"https://api.github.com/users/stof/repos","events_url":"https://api.github.com/users/stof/events{/privacy}","received_events_url":"https://api.github.com/users/stof/received_events","type":"User","site_admin":false},"body":"| Q             | A\r\n| ------------- | ---\r\n| Bug fix?      | no\r\n| New feature?  | no\r\n| BC breaks?    | no\r\n| Deprecations? | no\r\n| Tests pass?   | yes\r\n| Fixed tickets | n/a\r\n| License       | MIT\r\n| Doc PR        | n/a\r\n\r\nI ran Blackfire on the [Mink BrowserKitDriver](https://github.com/minkphp/MinkBrowserKitDriver) testsuite (which is a realistic usage of the Mink API btw, as the driver testsuite is basically a functional test of a fixtures website, where failures are considered to be caused by the driver misbehaving).\r\nI discovered that 17% of the time was spent in ``preg_match_all`` to look for prefixes in the XPath namespace prefixes (Mink does not use any namespace prefix in its Xpath queries).\r\n\r\nThis optimizes the regex to use a possessive quantifier. This avoids useless backtracking when matching (due to the way the regex is written, backtracking cannot allow finding more matches here). See https://blackfire.io/profiles/compare/21aaebf3-e38f-456a-8fc9-cf7d9e2a35eb/graph for the improvement.\r\nThe optimization is applied in the 2.7 branch, because this regex does not exist in 2.3: the registration of namespaces was added in 2.4","created_at":"2015-09-20T21:33:07Z","updated_at":"2015-09-20T21:33:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/symfony/symfony/pulls/15847/commits","review_comments_url":"https://api.github.com/repos/symfony/symfony/pulls/15847/comments","review_comment_url":"https://api.github.com/repos/symfony/symfony/pulls/comments{/number}","comments_url":"https://api.github.com/repos/symfony/symfony/issues/15847/comments","statuses_url":"https://api.github.com/repos/symfony/symfony/statuses/02818e4c92d86e58790cd74e35483dc9ada02590","head":{"label":"stof:crawler_optimization","ref":"crawler_optimization","sha":"02818e4c92d86e58790cd74e35483dc9ada02590","user":{"login":"stof","id":439401,"avatar_url":"https://avatars.githubusercontent.com/u/439401?v=3","gravatar_id":"","url":"https://api.github.com/users/stof","html_url":"https://github.com/stof","followers_url":"https://api.github.com/users/stof/followers","following_url":"https://api.github.com/users/stof/following{/other_user}","gists_url":"https://api.github.com/users/stof/gists{/gist_id}","starred_url":"https://api.github.com/users/stof/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stof/subscriptions","organizations_url":"https://api.github.com/users/stof/orgs","repos_url":"https://api.github.com/users/stof/repos","events_url":"https://api.github.com/users/stof/events{/privacy}","received_events_url":"https://api.github.com/users/stof/received_events","type":"User","site_admin":false},"repo":{"id":1399043,"name":"symfony","full_name":"stof/symfony","owner":{"login":"stof","id":439401,"avatar_url":"https://avatars.githubusercontent.com/u/439401?v=3","gravatar_id":"","url":"https://api.github.com/users/stof","html_url":"https://github.com/stof","followers_url":"https://api.github.com/users/stof/followers","following_url":"https://api.github.com/users/stof/following{/other_user}","gists_url":"https://api.github.com/users/stof/gists{/gist_id}","starred_url":"https://api.github.com/users/stof/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stof/subscriptions","organizations_url":"https://api.github.com/users/stof/orgs","repos_url":"https://api.github.com/users/stof/repos","events_url":"https://api.github.com/users/stof/events{/privacy}","received_events_url":"https://api.github.com/users/stof/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/stof/symfony","description":"The Symfony2 PHP framework (PHP 5.3 only -- not yet stable) -- documentation for master is at http://docs.symfony-reloaded.org/master/","fork":true,"url":"https://api.github.com/repos/stof/symfony","forks_url":"https://api.github.com/repos/stof/symfony/forks","keys_url":"https://api.github.com/repos/stof/symfony/keys{/key_id}","collaborators_url":"https://api.github.com/repos/stof/symfony/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/stof/symfony/teams","hooks_url":"https://api.github.com/repos/stof/symfony/hooks","issue_events_url":"https://api.github.com/repos/stof/symfony/issues/events{/number}","events_url":"https://api.github.com/repos/stof/symfony/events","assignees_url":"https://api.github.com/repos/stof/symfony/assignees{/user}","branches_url":"https://api.github.com/repos/stof/symfony/branches{/branch}","tags_url":"https://api.github.com/repos/stof/symfony/tags","blobs_url":"https://api.github.com/repos/stof/symfony/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/stof/symfony/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/stof/symfony/git/refs{/sha}","trees_url":"https://api.github.com/repos/stof/symfony/git/trees{/sha}","statuses_url":"https://api.github.com/repos/stof/symfony/statuses/{sha}","languages_url":"https://api.github.com/repos/stof/symfony/languages","stargazers_url":"https://api.github.com/repos/stof/symfony/stargazers","contributors_url":"https://api.github.com/repos/stof/symfony/contributors","subscribers_url":"https://api.github.com/repos/stof/symfony/subscribers","subscription_url":"https://api.github.com/repos/stof/symfony/subscription","commits_url":"https://api.github.com/repos/stof/symfony/commits{/sha}","git_commits_url":"https://api.github.com/repos/stof/symfony/git/commits{/sha}","comments_url":"https://api.github.com/repos/stof/symfony/comments{/number}","issue_comment_url":"https://api.github.com/repos/stof/symfony/issues/comments{/number}","contents_url":"https://api.github.com/repos/stof/symfony/contents/{+path}","compare_url":"https://api.github.com/repos/stof/symfony/compare/{base}...{head}","merges_url":"https://api.github.com/repos/stof/symfony/merges","archive_url":"https://api.github.com/repos/stof/symfony/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/stof/symfony/downloads","issues_url":"https://api.github.com/repos/stof/symfony/issues{/number}","pulls_url":"https://api.github.com/repos/stof/symfony/pulls{/number}","milestones_url":"https://api.github.com/repos/stof/symfony/milestones{/number}","notifications_url":"https://api.github.com/repos/stof/symfony/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/stof/symfony/labels{/name}","releases_url":"https://api.github.com/repos/stof/symfony/releases{/id}","created_at":"2011-02-22T19:38:18Z","updated_at":"2015-03-22T15:37:35Z","pushed_at":"2015-09-20T21:14:51Z","git_url":"git://github.com/stof/symfony.git","ssh_url":"git@github.com:stof/symfony.git","clone_url":"https://github.com/stof/symfony.git","svn_url":"https://github.com/stof/symfony","homepage":"http://www.symfony-reloaded.org/","size":59667,"stargazers_count":2,"watchers_count":2,"language":"PHP","has_issues":false,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":2,"default_branch":"master"}},"base":{"label":"symfony:2.7","ref":"2.7","sha":"f64cf23811f3b96103e0656c0881c18301bcc41c","user":{"login":"symfony","id":143937,"avatar_url":"https://avatars.githubusercontent.com/u/143937?v=3","gravatar_id":"","url":"https://api.github.com/users/symfony","html_url":"https://github.com/symfony","followers_url":"https://api.github.com/users/symfony/followers","following_url":"https://api.github.com/users/symfony/following{/other_user}","gists_url":"https://api.github.com/users/symfony/gists{/gist_id}","starred_url":"https://api.github.com/users/symfony/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/symfony/subscriptions","organizations_url":"https://api.github.com/users/symfony/orgs","repos_url":"https://api.github.com/users/symfony/repos","events_url":"https://api.github.com/users/symfony/events{/privacy}","received_events_url":"https://api.github.com/users/symfony/received_events","type":"Organization","site_admin":false},"repo":{"id":458058,"name":"symfony","full_name":"symfony/symfony","owner":{"login":"symfony","id":143937,"avatar_url":"https://avatars.githubusercontent.com/u/143937?v=3","gravatar_id":"","url":"https://api.github.com/users/symfony","html_url":"https://github.com/symfony","followers_url":"https://api.github.com/users/symfony/followers","following_url":"https://api.github.com/users/symfony/following{/other_user}","gists_url":"https://api.github.com/users/symfony/gists{/gist_id}","starred_url":"https://api.github.com/users/symfony/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/symfony/subscriptions","organizations_url":"https://api.github.com/users/symfony/orgs","repos_url":"https://api.github.com/users/symfony/repos","events_url":"https://api.github.com/users/symfony/events{/privacy}","received_events_url":"https://api.github.com/users/symfony/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/symfony/symfony","description":"The Symfony PHP framework","fork":false,"url":"https://api.github.com/repos/symfony/symfony","forks_url":"https://api.github.com/repos/symfony/symfony/forks","keys_url":"https://api.github.com/repos/symfony/symfony/keys{/key_id}","collaborators_url":"https://api.github.com/repos/symfony/symfony/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/symfony/symfony/teams","hooks_url":"https://api.github.com/repos/symfony/symfony/hooks","issue_events_url":"https://api.github.com/repos/symfony/symfony/issues/events{/number}","events_url":"https://api.github.com/repos/symfony/symfony/events","assignees_url":"https://api.github.com/repos/symfony/symfony/assignees{/user}","branches_url":"https://api.github.com/repos/symfony/symfony/branches{/branch}","tags_url":"https://api.github.com/repos/symfony/symfony/tags","blobs_url":"https://api.github.com/repos/symfony/symfony/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/symfony/symfony/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/symfony/symfony/git/refs{/sha}","trees_url":"https://api.github.com/repos/symfony/symfony/git/trees{/sha}","statuses_url":"https://api.github.com/repos/symfony/symfony/statuses/{sha}","languages_url":"https://api.github.com/repos/symfony/symfony/languages","stargazers_url":"https://api.github.com/repos/symfony/symfony/stargazers","contributors_url":"https://api.github.com/repos/symfony/symfony/contributors","subscribers_url":"https://api.github.com/repos/symfony/symfony/subscribers","subscription_url":"https://api.github.com/repos/symfony/symfony/subscription","commits_url":"https://api.github.com/repos/symfony/symfony/commits{/sha}","git_commits_url":"https://api.github.com/repos/symfony/symfony/git/commits{/sha}","comments_url":"https://api.github.com/repos/symfony/symfony/comments{/number}","issue_comment_url":"https://api.github.com/repos/symfony/symfony/issues/comments{/number}","contents_url":"https://api.github.com/repos/symfony/symfony/contents/{+path}","compare_url":"https://api.github.com/repos/symfony/symfony/compare/{base}...{head}","merges_url":"https://api.github.com/repos/symfony/symfony/merges","archive_url":"https://api.github.com/repos/symfony/symfony/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/symfony/symfony/downloads","issues_url":"https://api.github.com/repos/symfony/symfony/issues{/number}","pulls_url":"https://api.github.com/repos/symfony/symfony/pulls{/number}","milestones_url":"https://api.github.com/repos/symfony/symfony/milestones{/number}","notifications_url":"https://api.github.com/repos/symfony/symfony/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/symfony/symfony/labels{/name}","releases_url":"https://api.github.com/repos/symfony/symfony/releases{/id}","created_at":"2010-01-04T14:21:21Z","updated_at":"2015-09-20T15:28:13Z","pushed_at":"2015-09-20T21:08:08Z","git_url":"git://github.com/symfony/symfony.git","ssh_url":"git@github.com:symfony/symfony.git","clone_url":"https://github.com/symfony/symfony.git","svn_url":"https://github.com/symfony/symfony","homepage":"symfony.com","size":249622,"stargazers_count":10804,"watchers_count":10804,"language":"PHP","has_issues":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":4261,"mirror_url":null,"open_issues_count":937,"forks":4261,"open_issues":937,"watchers":10804,"default_branch":"2.8"}},"_links":{"self":{"href":"https://api.github.com/repos/symfony/symfony/pulls/15847"},"html":{"href":"https://github.com/symfony/symfony/pull/15847"},"issue":{"href":"https://api.github.com/repos/symfony/symfony/issues/15847"},"comments":{"href":"https://api.github.com/repos/symfony/symfony/issues/15847/comments"},"review_comments":{"href":"https://api.github.com/repos/symfony/symfony/pulls/15847/comments"},"review_comment":{"href":"https://api.github.com/repos/symfony/symfony/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/symfony/symfony/pulls/15847/commits"},"statuses":{"href":"https://api.github.com/repos/symfony/symfony/statuses/02818e4c92d86e58790cd74e35483dc9ada02590"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":1,"additions":2,"deletions":2,"changed_files":1}}