From 32c6c99e0b0172e13dd761f3378b328d1e6a6dab Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Sat, 20 Apr 2002 21:56:15 +0000 Subject: Scanner performance improvements Use flex flags -CF. Pass the to-be-scanned string around as StringInfo type, to avoid querying the length repeatedly. Clean up some code and remove lex-compatibility cruft. Escape backslash sequences inline. Use flex-provided yy_scan_buffer() function to set up input, rather than using myinput(). --- src/backend/parser/parser.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) (limited to 'src/backend/parser/parser.c') diff --git a/src/backend/parser/parser.c b/src/backend/parser/parser.c index f83d04e69cc..4eadbef5f44 100644 --- a/src/backend/parser/parser.c +++ b/src/backend/parser/parser.c @@ -14,7 +14,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/parser.c,v 1.51 2001/11/05 17:46:26 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/parser.c,v 1.52 2002/04/20 21:56:14 petere Exp $ * *------------------------------------------------------------------------- */ @@ -28,12 +28,6 @@ #include "parser/parse_expr.h" -#if defined(FLEX_SCANNER) -extern void DeleteBuffer(void); -#endif /* FLEX_SCANNER */ - -char *parseString; /* the char* which holds the string to be - * parsed */ List *parsetree; /* result of parsing is left here */ static int lookahead_token; /* one-token lookahead */ @@ -48,24 +42,20 @@ static bool have_lookahead; /* lookahead_token set? */ * Returns a list of raw (un-analyzed) parse trees. */ List * -parser(char *str, Oid *typev, int nargs) +parser(StringInfo str, Oid *typev, int nargs) { int yyresult; - parseString = str; parsetree = NIL; /* in case parser forgets to set it */ have_lookahead = false; - scanner_init(); + scanner_init(str); parser_init(typev, nargs); parse_expr_init(); yyresult = yyparse(); -#if defined(FLEX_SCANNER) - DeleteBuffer(); -#endif /* FLEX_SCANNER */ - + scanner_finish(); clearerr(stdin); if (yyresult) /* error */ -- cgit v1.2.3