{"action":"created","comment":{"url":"https://api.github.com/repos/google/jsonnet/pulls/comments/154665085","pull_request_review_id":80860034,"id":154665085,"diff_hunk":"@@ -282,70 +282,50 @@ void CompilerPass::visit(Unary *ast)\n     expr(ast->expr);\n }\n \n+#define VISIT(var,astType,astClass) \\\n+   case astType: { \\\n+     assert(dynamic_cast<astClass *>(var)); \\\n+     auto *ast = static_cast<astClass *>(var); \\\n+     visit(ast); \\\n+   } break\n+\n void CompilerPass::visitExpr(AST *&ast_)\n {\n-    if (auto *ast = dynamic_cast<Apply *>(ast_)) {\n-        visit(ast);\n-    } else if (auto *ast = dynamic_cast<ApplyBrace *>(ast_)) {\n-        visit(ast);\n-    } else if (auto *ast = dynamic_cast<Array *>(ast_)) {\n-        visit(ast);\n-    } else if (auto *ast = dynamic_cast<ArrayComprehension *>(ast_)) {\n-        visit(ast);\n-    } else if (auto *ast = dynamic_cast<Assert *>(ast_)) {\n-        visit(ast);\n-    } else if (auto *ast = dynamic_cast<Binary *>(ast_)) {\n-        visit(ast);\n-    } else if (auto *ast = dynamic_cast<BuiltinFunction *>(ast_)) {\n-        visit(ast);\n-    } else if (auto *ast = dynamic_cast<Conditional *>(ast_)) {\n-        visit(ast);\n-    } else if (auto *ast = dynamic_cast<Dollar *>(ast_)) {\n-        visit(ast);\n-    } else if (auto *ast = dynamic_cast<Error *>(ast_)) {\n-        visit(ast);\n-    } else if (auto *ast = dynamic_cast<Function *>(ast_)) {\n-        visit(ast);\n-    } else if (auto *ast = dynamic_cast<Import *>(ast_)) {\n-        visit(ast);\n-    } else if (auto *ast = dynamic_cast<Importstr *>(ast_)) {\n-        visit(ast);\n-    } else if (auto *ast = dynamic_cast<InSuper *>(ast_)) {\n-        visit(ast);\n-    } else if (auto *ast = dynamic_cast<Index *>(ast_)) {\n-        visit(ast);\n-    } else if (auto *ast = dynamic_cast<Local *>(ast_)) {\n-        visit(ast);\n-    } else if (auto *ast = dynamic_cast<LiteralBoolean *>(ast_)) {\n-        visit(ast);\n-    } else if (auto *ast = dynamic_cast<LiteralNumber *>(ast_)) {\n-        visit(ast);\n-    } else if (auto *ast = dynamic_cast<LiteralString *>(ast_)) {\n-        visit(ast);\n-    } else if (auto *ast = dynamic_cast<LiteralNull *>(ast_)) {\n-        visit(ast);\n-    } else if (auto *ast = dynamic_cast<Object *>(ast_)) {\n-        visit(ast);\n-    } else if (auto *ast = dynamic_cast<DesugaredObject *>(ast_)) {\n-        visit(ast);\n-    } else if (auto *ast = dynamic_cast<ObjectComprehension *>(ast_)) {\n-        visit(ast);\n-    } else if (auto *ast = dynamic_cast<ObjectComprehensionSimple *>(ast_)) {\n-        visit(ast);\n-    } else if (auto *ast = dynamic_cast<Parens *>(ast_)) {\n-        visit(ast);\n-    } else if (auto *ast = dynamic_cast<Self *>(ast_)) {\n-        visit(ast);\n-    } else if (auto *ast = dynamic_cast<SuperIndex *>(ast_)) {\n-        visit(ast);\n-    } else if (auto *ast = dynamic_cast<Unary *>(ast_)) {\n-        visit(ast);\n-    } else if (auto *ast = dynamic_cast<Var *>(ast_)) {\n-        visit(ast);\n-\n-    } else {\n-        std::cerr << \"INTERNAL ERROR: Unknown AST: \" << ast_ << std::endl;\n-        std::abort();\n+    switch(ast_->type) {\n+        VISIT(ast_, AST_APPLY, Apply);\n+        VISIT(ast_, AST_APPLY_BRACE, ApplyBrace);\n+        VISIT(ast_, AST_ARRAY, Array);\n+        VISIT(ast_, AST_ARRAY_COMPREHENSION, ArrayComprehension);\n+        // VISIT(ast_, AST_ARRAY_COMPREHENSION, ArrayComprehensionSimple);","path":"core/pass.cpp","position":80,"original_position":80,"commit_id":"45811604cebe5a2bb762cc9f6e0a2096c64972dd","original_commit_id":"762a1372c956724a24481ddb2d64976b2b02baf4","user":{"login":"sparkprime","id":168158,"avatar_url":"https://avatars0.githubusercontent.com/u/168158?v=4","gravatar_id":"","url":"https://api.github.com/users/sparkprime","html_url":"https://github.com/sparkprime","followers_url":"https://api.github.com/users/sparkprime/followers","following_url":"https://api.github.com/users/sparkprime/following{/other_user}","gists_url":"https://api.github.com/users/sparkprime/gists{/gist_id}","starred_url":"https://api.github.com/users/sparkprime/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sparkprime/subscriptions","organizations_url":"https://api.github.com/users/sparkprime/orgs","repos_url":"https://api.github.com/users/sparkprime/repos","events_url":"https://api.github.com/users/sparkprime/events{/privacy}","received_events_url":"https://api.github.com/users/sparkprime/received_events","type":"User","site_admin":false},"body":"I think all these passes run before desugaring, so there should not be any ArrayComprehensionSimple.  That could change in future of course.","created_at":"2017-12-04T14:38:48Z","updated_at":"2017-12-04T14:38:48Z","html_url":"https://github.com/google/jsonnet/pull/416#discussion_r154665085","pull_request_url":"https://api.github.com/repos/google/jsonnet/pulls/416","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/google/jsonnet/pulls/comments/154665085"},"html":{"href":"https://github.com/google/jsonnet/pull/416#discussion_r154665085"},"pull_request":{"href":"https://api.github.com/repos/google/jsonnet/pulls/416"}},"in_reply_to_id":154521888},"pull_request":{"url":"https://api.github.com/repos/google/jsonnet/pulls/416","id":156046621,"html_url":"https://github.com/google/jsonnet/pull/416","diff_url":"https://github.com/google/jsonnet/pull/416.diff","patch_url":"https://github.com/google/jsonnet/pull/416.patch","issue_url":"https://api.github.com/repos/google/jsonnet/issues/416","number":416,"state":"open","locked":false,"title":"Use directly static_cast, rather than probing with dynamic_cast","user":{"login":"malkia","id":51738,"avatar_url":"https://avatars2.githubusercontent.com/u/51738?v=4","gravatar_id":"","url":"https://api.github.com/users/malkia","html_url":"https://github.com/malkia","followers_url":"https://api.github.com/users/malkia/followers","following_url":"https://api.github.com/users/malkia/following{/other_user}","gists_url":"https://api.github.com/users/malkia/gists{/gist_id}","starred_url":"https://api.github.com/users/malkia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/malkia/subscriptions","organizations_url":"https://api.github.com/users/malkia/orgs","repos_url":"https://api.github.com/users/malkia/repos","events_url":"https://api.github.com/users/malkia/events{/privacy}","received_events_url":"https://api.github.com/users/malkia/received_events","type":"User","site_admin":false},"body":"Instead of probing and dynamic_cast-ing one, by one, use a switch over the stored AST node type, and then static_cast. This change speeds up ~2x times the evalution of  \r\nhttps://github.com/ksonnet/ksonnet-lib/blob/master/examples/readme/hello-nginx.jsonnet\r\n\r\nIn addition:\r\n- Added AST_APPLY_BRACE, as previously it was piggybacking on AST_BINARY\r\n- Changed ASTs from std::vector<> to std::list<> as elements are not read by index, but one by one, and avoid reallocations. fwd_list might be even a better choice.","created_at":"2017-12-03T05:26:29Z","updated_at":"2017-12-04T14:38:48Z","closed_at":null,"merged_at":null,"merge_commit_sha":"923efead739acf68fa3d54d79a5c950f1b2dc2eb","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/google/jsonnet/pulls/416/commits","review_comments_url":"https://api.github.com/repos/google/jsonnet/pulls/416/comments","review_comment_url":"https://api.github.com/repos/google/jsonnet/pulls/comments{/number}","comments_url":"https://api.github.com/repos/google/jsonnet/issues/416/comments","statuses_url":"https://api.github.com/repos/google/jsonnet/statuses/45811604cebe5a2bb762cc9f6e0a2096c64972dd","head":{"label":"malkia:master","ref":"master","sha":"45811604cebe5a2bb762cc9f6e0a2096c64972dd","user":{"login":"malkia","id":51738,"avatar_url":"https://avatars2.githubusercontent.com/u/51738?v=4","gravatar_id":"","url":"https://api.github.com/users/malkia","html_url":"https://github.com/malkia","followers_url":"https://api.github.com/users/malkia/followers","following_url":"https://api.github.com/users/malkia/following{/other_user}","gists_url":"https://api.github.com/users/malkia/gists{/gist_id}","starred_url":"https://api.github.com/users/malkia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/malkia/subscriptions","organizations_url":"https://api.github.com/users/malkia/orgs","repos_url":"https://api.github.com/users/malkia/repos","events_url":"https://api.github.com/users/malkia/events{/privacy}","received_events_url":"https://api.github.com/users/malkia/received_events","type":"User","site_admin":false},"repo":{"id":109170741,"name":"jsonnet","full_name":"malkia/jsonnet","owner":{"login":"malkia","id":51738,"avatar_url":"https://avatars2.githubusercontent.com/u/51738?v=4","gravatar_id":"","url":"https://api.github.com/users/malkia","html_url":"https://github.com/malkia","followers_url":"https://api.github.com/users/malkia/followers","following_url":"https://api.github.com/users/malkia/following{/other_user}","gists_url":"https://api.github.com/users/malkia/gists{/gist_id}","starred_url":"https://api.github.com/users/malkia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/malkia/subscriptions","organizations_url":"https://api.github.com/users/malkia/orgs","repos_url":"https://api.github.com/users/malkia/repos","events_url":"https://api.github.com/users/malkia/events{/privacy}","received_events_url":"https://api.github.com/users/malkia/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/malkia/jsonnet","description":"Jsonnet - The data templating language","fork":true,"url":"https://api.github.com/repos/malkia/jsonnet","forks_url":"https://api.github.com/repos/malkia/jsonnet/forks","keys_url":"https://api.github.com/repos/malkia/jsonnet/keys{/key_id}","collaborators_url":"https://api.github.com/repos/malkia/jsonnet/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/malkia/jsonnet/teams","hooks_url":"https://api.github.com/repos/malkia/jsonnet/hooks","issue_events_url":"https://api.github.com/repos/malkia/jsonnet/issues/events{/number}","events_url":"https://api.github.com/repos/malkia/jsonnet/events","assignees_url":"https://api.github.com/repos/malkia/jsonnet/assignees{/user}","branches_url":"https://api.github.com/repos/malkia/jsonnet/branches{/branch}","tags_url":"https://api.github.com/repos/malkia/jsonnet/tags","blobs_url":"https://api.github.com/repos/malkia/jsonnet/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/malkia/jsonnet/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/malkia/jsonnet/git/refs{/sha}","trees_url":"https://api.github.com/repos/malkia/jsonnet/git/trees{/sha}","statuses_url":"https://api.github.com/repos/malkia/jsonnet/statuses/{sha}","languages_url":"https://api.github.com/repos/malkia/jsonnet/languages","stargazers_url":"https://api.github.com/repos/malkia/jsonnet/stargazers","contributors_url":"https://api.github.com/repos/malkia/jsonnet/contributors","subscribers_url":"https://api.github.com/repos/malkia/jsonnet/subscribers","subscription_url":"https://api.github.com/repos/malkia/jsonnet/subscription","commits_url":"https://api.github.com/repos/malkia/jsonnet/commits{/sha}","git_commits_url":"https://api.github.com/repos/malkia/jsonnet/git/commits{/sha}","comments_url":"https://api.github.com/repos/malkia/jsonnet/comments{/number}","issue_comment_url":"https://api.github.com/repos/malkia/jsonnet/issues/comments{/number}","contents_url":"https://api.github.com/repos/malkia/jsonnet/contents/{+path}","compare_url":"https://api.github.com/repos/malkia/jsonnet/compare/{base}...{head}","merges_url":"https://api.github.com/repos/malkia/jsonnet/merges","archive_url":"https://api.github.com/repos/malkia/jsonnet/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/malkia/jsonnet/downloads","issues_url":"https://api.github.com/repos/malkia/jsonnet/issues{/number}","pulls_url":"https://api.github.com/repos/malkia/jsonnet/pulls{/number}","milestones_url":"https://api.github.com/repos/malkia/jsonnet/milestones{/number}","notifications_url":"https://api.github.com/repos/malkia/jsonnet/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/malkia/jsonnet/labels{/name}","releases_url":"https://api.github.com/repos/malkia/jsonnet/releases{/id}","deployments_url":"https://api.github.com/repos/malkia/jsonnet/deployments","created_at":"2017-11-01T18:53:23Z","updated_at":"2017-11-01T18:53:25Z","pushed_at":"2017-12-03T19:47:24Z","git_url":"git://github.com/malkia/jsonnet.git","ssh_url":"git@github.com:malkia/jsonnet.git","clone_url":"https://github.com/malkia/jsonnet.git","svn_url":"https://github.com/malkia/jsonnet","homepage":"http://jsonnet.org","size":18264,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"google:master","ref":"master","sha":"d8d3f88bb2a04665fec9c9ea30ffeb54a86d5826","user":{"login":"google","id":1342004,"avatar_url":"https://avatars1.githubusercontent.com/u/1342004?v=4","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"repo":{"id":22527161,"name":"jsonnet","full_name":"google/jsonnet","owner":{"login":"google","id":1342004,"avatar_url":"https://avatars1.githubusercontent.com/u/1342004?v=4","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/google/jsonnet","description":"Jsonnet - The data templating language","fork":false,"url":"https://api.github.com/repos/google/jsonnet","forks_url":"https://api.github.com/repos/google/jsonnet/forks","keys_url":"https://api.github.com/repos/google/jsonnet/keys{/key_id}","collaborators_url":"https://api.github.com/repos/google/jsonnet/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/google/jsonnet/teams","hooks_url":"https://api.github.com/repos/google/jsonnet/hooks","issue_events_url":"https://api.github.com/repos/google/jsonnet/issues/events{/number}","events_url":"https://api.github.com/repos/google/jsonnet/events","assignees_url":"https://api.github.com/repos/google/jsonnet/assignees{/user}","branches_url":"https://api.github.com/repos/google/jsonnet/branches{/branch}","tags_url":"https://api.github.com/repos/google/jsonnet/tags","blobs_url":"https://api.github.com/repos/google/jsonnet/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/google/jsonnet/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/google/jsonnet/git/refs{/sha}","trees_url":"https://api.github.com/repos/google/jsonnet/git/trees{/sha}","statuses_url":"https://api.github.com/repos/google/jsonnet/statuses/{sha}","languages_url":"https://api.github.com/repos/google/jsonnet/languages","stargazers_url":"https://api.github.com/repos/google/jsonnet/stargazers","contributors_url":"https://api.github.com/repos/google/jsonnet/contributors","subscribers_url":"https://api.github.com/repos/google/jsonnet/subscribers","subscription_url":"https://api.github.com/repos/google/jsonnet/subscription","commits_url":"https://api.github.com/repos/google/jsonnet/commits{/sha}","git_commits_url":"https://api.github.com/repos/google/jsonnet/git/commits{/sha}","comments_url":"https://api.github.com/repos/google/jsonnet/comments{/number}","issue_comment_url":"https://api.github.com/repos/google/jsonnet/issues/comments{/number}","contents_url":"https://api.github.com/repos/google/jsonnet/contents/{+path}","compare_url":"https://api.github.com/repos/google/jsonnet/compare/{base}...{head}","merges_url":"https://api.github.com/repos/google/jsonnet/merges","archive_url":"https://api.github.com/repos/google/jsonnet/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/google/jsonnet/downloads","issues_url":"https://api.github.com/repos/google/jsonnet/issues{/number}","pulls_url":"https://api.github.com/repos/google/jsonnet/pulls{/number}","milestones_url":"https://api.github.com/repos/google/jsonnet/milestones{/number}","notifications_url":"https://api.github.com/repos/google/jsonnet/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/google/jsonnet/labels{/name}","releases_url":"https://api.github.com/repos/google/jsonnet/releases{/id}","deployments_url":"https://api.github.com/repos/google/jsonnet/deployments","created_at":"2014-08-01T20:29:12Z","updated_at":"2017-12-03T20:19:26Z","pushed_at":"2017-12-03T19:47:25Z","git_url":"git://github.com/google/jsonnet.git","ssh_url":"git@github.com:google/jsonnet.git","clone_url":"https://github.com/google/jsonnet.git","svn_url":"https://github.com/google/jsonnet","homepage":"http://jsonnet.org","size":18265,"stargazers_count":986,"watchers_count":986,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":131,"mirror_url":null,"archived":false,"open_issues_count":101,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":131,"open_issues":101,"watchers":986,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/google/jsonnet/pulls/416"},"html":{"href":"https://github.com/google/jsonnet/pull/416"},"issue":{"href":"https://api.github.com/repos/google/jsonnet/issues/416"},"comments":{"href":"https://api.github.com/repos/google/jsonnet/issues/416/comments"},"review_comments":{"href":"https://api.github.com/repos/google/jsonnet/pulls/416/comments"},"review_comment":{"href":"https://api.github.com/repos/google/jsonnet/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/google/jsonnet/pulls/416/commits"},"statuses":{"href":"https://api.github.com/repos/google/jsonnet/statuses/45811604cebe5a2bb762cc9f6e0a2096c64972dd"}},"author_association":"NONE"}}
{"actor":{"display_login":"sparkprime"}}