Try to speed up parsing a little
This commit is contained in:
parent
76ec285c58
commit
880f97f004
@ -22,7 +22,9 @@ upstream_sources = \
|
||||
gtksourcestylescheme.h \
|
||||
gtktextregion.h \
|
||||
gtksourceview-utils.h \
|
||||
gtksourceview-utils.c
|
||||
gtksourceview-utils.c \
|
||||
gtksourcelanguage-noxml.c \
|
||||
gtksourcestylescheme-noxml.c
|
||||
|
||||
EXTRA_DIST = $(upstream_sources) mangle.sh
|
||||
|
||||
|
@ -2521,6 +2521,7 @@ regex_new (const gchar *pattern,
|
||||
GError **error)
|
||||
{
|
||||
Regex *regex;
|
||||
static GRegex *start_ref_re = NULL;
|
||||
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
||||
|
||||
@ -2535,7 +2536,10 @@ regex_new (const gchar *pattern,
|
||||
regex = g_slice_new0 (Regex);
|
||||
regex->ref_count = 1;
|
||||
|
||||
if (g_regex_match_simple (START_REF_REGEX, pattern, 0, 0))
|
||||
if (start_ref_re == NULL)
|
||||
start_ref_re = g_regex_new (START_REF_REGEX, G_REGEX_OPTIMIZE, 0, NULL);
|
||||
|
||||
if (g_regex_match (start_ref_re, pattern, 0, NULL))
|
||||
{
|
||||
regex->resolved = FALSE;
|
||||
regex->u.info.pattern = g_strdup (pattern);
|
||||
|
@ -1042,12 +1042,13 @@ expand_regex_delimiters (ParserState *parser_state,
|
||||
*/
|
||||
const gchar *re = "(?<!\\\\)(\\\\\\\\)*\\\\%(\\[|\\])";
|
||||
gchar *expanded_regex;
|
||||
GRegex *egg_re;
|
||||
static GRegex *egg_re;
|
||||
|
||||
if (regex == NULL)
|
||||
return NULL;
|
||||
|
||||
egg_re = g_regex_new (re, 0, 0, NULL);
|
||||
if (egg_re == NULL)
|
||||
egg_re = g_regex_new (re, G_REGEX_OPTIMIZE, 0, NULL);
|
||||
|
||||
expanded_regex = g_regex_replace_eval (egg_re, regex, len, 0, 0,
|
||||
replace_delimiter, parser_state, NULL);
|
||||
@ -1055,8 +1056,6 @@ expand_regex_delimiters (ParserState *parser_state,
|
||||
DEBUG (g_message ("expanded regex delims '%s' to '%s'",
|
||||
regex, expanded_regex));
|
||||
|
||||
g_regex_unref (egg_re);
|
||||
|
||||
return expanded_regex;
|
||||
}
|
||||
|
||||
@ -1070,6 +1069,7 @@ expand_regex (ParserState *parser_state,
|
||||
{
|
||||
gchar *tmp_regex;
|
||||
GString *expanded_regex;
|
||||
static GRegex *backref_re = NULL;
|
||||
|
||||
g_assert (parser_state != NULL);
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
||||
@ -1077,14 +1077,18 @@ expand_regex (ParserState *parser_state,
|
||||
if (regex == NULL)
|
||||
return NULL;
|
||||
|
||||
if (g_regex_match_simple ("(?<!\\\\)(\\\\\\\\)*\\\\[0-9]", regex, 0, 0))
|
||||
if (backref_re == NULL)
|
||||
backref_re = g_regex_new ("(?<!\\\\)(\\\\\\\\)*\\\\[0-9]",
|
||||
G_REGEX_OPTIMIZE, 0, NULL);
|
||||
|
||||
if (g_regex_match (backref_re, regex, 0, NULL))
|
||||
{
|
||||
/* This may be a backreference, or it may be an octal character */
|
||||
GRegex *compiled;
|
||||
|
||||
compiled = g_regex_new (regex, flags, 0, error);
|
||||
|
||||
if (!compiled)
|
||||
if (compiled == NULL)
|
||||
return NULL;
|
||||
|
||||
if (g_regex_get_max_backref (compiled) > 0)
|
||||
|
@ -12,15 +12,10 @@ langs="ada.lang awk.lang changelog.lang chdr.lang c.lang cpp.lang csharp.lang
|
||||
python.lang ruby.lang scheme.lang sh.lang sql.lang tcl.lang
|
||||
texinfo.lang verilog.lang xml.lang yacc.lang"
|
||||
|
||||
styles="gvim.xml kate.xml testdark.xml tango.xml"
|
||||
styles="gvim.xml kate.xml"
|
||||
|
||||
if [ $1 ]; then
|
||||
langs=$*
|
||||
styles=
|
||||
fi
|
||||
|
||||
for file in $langs $styles; do
|
||||
case $file in
|
||||
check_file() {
|
||||
case $1 in
|
||||
*.xml)
|
||||
xmllint --relaxng styles.rng --noout $file || exit 1
|
||||
;;
|
||||
@ -28,4 +23,19 @@ for file in $langs $styles; do
|
||||
xmllint --relaxng language2.rng --noout $file || exit 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
if [ $1 ]; then
|
||||
for file in $@; do
|
||||
check_file $file
|
||||
done
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$srcdir" ]; then
|
||||
cd $srcdir
|
||||
fi
|
||||
|
||||
for file in $langs $styles; do
|
||||
check_file $file
|
||||
done
|
||||
|
Loading…
x
Reference in New Issue
Block a user