summaryrefslogtreecommitdiff
path: root/src/parser/parsers.h
diff options
context:
space:
mode:
authorThomas Lively <tlively@google.com>2024-04-19 17:07:43 -0700
committerGitHub <noreply@github.com>2024-04-19 17:07:43 -0700
commit219e668e87b012c0634043ed702534b8be31231f (patch)
treed482fb6ccbc165ea6709845d70f7d712672886f3 /src/parser/parsers.h
parentc60fe154ac09deb9227165d388c5f950bab6e052 (diff)
downloadbinaryen-219e668e87b012c0634043ed702534b8be31231f.tar.gz
binaryen-219e668e87b012c0634043ed702534b8be31231f.tar.bz2
binaryen-219e668e87b012c0634043ed702534b8be31231f.zip
[Parser][NFC] Do less work when parsing function types (#6516)
After the initial parsing pass to find the locations of all the module elements and after the type definitions have been parsed, the next phase of parsing is to visit all of the module elements and parse their types. This phase does not require parsing function bodies, but it previously parsed entire functions anyway for simplicity. To improve performance, skip that useless work.
Diffstat (limited to 'src/parser/parsers.h')
-rw-r--r--src/parser/parsers.h8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/parser/parsers.h b/src/parser/parsers.h
index bbb50b664..25078f354 100644
--- a/src/parser/parsers.h
+++ b/src/parser/parsers.h
@@ -3028,11 +3028,13 @@ template<typename Ctx> MaybeResult<> func(Ctx& ctx) {
CHECK_ERR(l);
localVars = *l;
}
- CHECK_ERR(instrs(ctx));
- ctx.setSrcLoc(ctx.in.takeAnnotations());
+ if (!ctx.skipFunctionBody()) {
+ CHECK_ERR(instrs(ctx));
+ ctx.setSrcLoc(ctx.in.takeAnnotations());
+ }
}
- if (!ctx.in.takeRParen()) {
+ if (!ctx.skipFunctionBody() && !ctx.in.takeRParen()) {
return ctx.in.err("expected end of function");
}