[m-rev.] for review: minor parser optimisation
Peter Wang
novalazy at gmail.com
Tue May 27 14:19:58 AEST 2008
Branches: main
A small optimisation for the parser. The speedup on tools/speedtest is about
0.78%
library/parser.m:
Add a mode declaration for `parser_get_token' that takes the expected
token as input, so that the expected and actual tokens can be unified
within the procedure. If they don't match, it avoids creating a new
parser state that would be discarded by the caller. The call in
`check_for_higher_order_term' is very likely to fail.
PS. The problem I'm trying to solve is the reading of .analysis files. When
making an .analysis file, reading in other analysis files can take nearly half
of the running time, mainly due to large structure sharing/reuse results.
Suggestions would be appreciated.
Index: library/parser.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/parser.m,v
retrieving revision 1.59
diff -u -r1.59 parser.m
--- library/parser.m 8 May 2008 00:57:31 -0000 1.59
+++ library/parser.m 27 May 2008 04:08:01 -0000
@@ -1018,14 +1018,17 @@
%-----------------------------------------------------------------------------%
-:- pred parser_get_token(token::out,
- state(Ops, T)::in, state(Ops, T)::out) is semidet.
+:- pred parser_get_token(token, state(Ops, T), state(Ops, T)).
+:- mode parser_get_token(in, in, out) is semidet.
+:- mode parser_get_token(out, in, out) is semidet.
parser_get_token(Token, !PS) :-
parser_get_token_context(Token, _Context, !PS).
-:- pred parser_get_token_context(token::out, token_context::out,
- state(Ops, T)::in, state(Ops, T)::out) is semidet.
+:- pred parser_get_token_context(token, token_context,
+ state(Ops, T), state(Ops, T)).
+:- mode parser_get_token_context(in, out, in, out) is semidet.
+:- mode parser_get_token_context(out, out, in, out) is semidet.
parser_get_token_context(Token, Context, ParserState0, ParserState) :-
Tokens0 = parser_state_get_tokens_left(ParserState0),
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to: mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions: mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the reviews
mailing list