Skip to content

Commit

Permalink
PuppetManifst: optimize resourceBody table
Browse files Browse the repository at this point in the history
Releated to universal-ctags#1912.
example.pp.zip submitted to universal-ctags#1921 is used to take a benchmark.

Before:
[yamato@master]~/var/ctags-github% time ./ctags --verbose /tmp/example.pp > /tmp/LOG 2>&1
./ctags --verbose /tmp/example.pp > /tmp/LOG 2>&1  142.32s user 21.10s system 99% cpu 2:43.67 total

After:
[yamato@master]~/var/ctags-github% time ./ctags --verbose /tmp/example.pp > /tmp/LOG 2>&1
./ctags --verbose /tmp/example.pp > /tmp/LOG 2>&1  73.08s user 17.89s system 99% cpu 1:31.16 total

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
  • Loading branch information
masatake committed Oct 8, 2018
1 parent a39e1de commit d80947a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
26 changes: 13 additions & 13 deletions optlib/puppetManifest.c
Original file line number Diff line number Diff line change
Expand Up @@ -462,32 +462,32 @@ static void initializePuppetManifestParser (const langType language CTAGS_ATTR_U
"^",
"", "", "{tquit}", NULL);
addLanguageTagMultiTableRegex (language, "resourceBody",
"^/\\*",
"", "", "{tenter=comment_multiline}", NULL);
addLanguageTagMultiTableRegex (language, "resourceBody",
"^\\#",
"", "", "{tenter=comment_oneline}", NULL);
addLanguageTagMultiTableRegex (language, "resourceBody",
"^[ \t\n]",
"^([^/#{'\";}<])",
"", "", "", NULL);
addLanguageTagMultiTableRegex (language, "resourceBody",
"^\\{",
"", "", "{tenter=skipBlock}", NULL);
addLanguageTagMultiTableRegex (language, "resourceBody",
"^'",
"", "", "{tenter=ssliteral}", NULL);
addLanguageTagMultiTableRegex (language, "resourceBody",
"^\"",
"", "", "{tenter=dsliteral}", NULL);
addLanguageTagMultiTableRegex (language, "resourceBody",
"^;",
"", "", "{tleave}{scope=pop}", NULL);
addLanguageTagMultiTableRegex (language, "resourceBody",
"^\\}",
"", "", "{tleave}{_advanceTo=0start}{scope=pop}", NULL);
addLanguageTagMultiTableRegex (language, "resourceBody",
"^\\{",
"", "", "{tenter=skipBlock}", NULL);
addLanguageTagMultiTableRegex (language, "resourceBody",
"^;",
"", "", "{tleave}{scope=pop}", NULL);
addLanguageTagMultiTableRegex (language, "resourceBody",
"^<<?\\|",
"", "", "{tenter=skipCollector}", NULL);
addLanguageTagMultiTableRegex (language, "resourceBody",
"^/\\*",
"", "", "{tenter=comment_multiline}", NULL);
addLanguageTagMultiTableRegex (language, "resourceBody",
"^\\#",
"", "", "{tenter=comment_oneline}", NULL);
addLanguageTagMultiTableRegex (language, "resourceBody",
"^.",
"", "", "", NULL);
Expand Down
12 changes: 8 additions & 4 deletions optlib/puppetManifest.ctags
Original file line number Diff line number Diff line change
Expand Up @@ -236,14 +236,18 @@
--_mtable-regex-PuppetManifest=resourceNameInArray/"([^"]+)"/\1/r/{tleave}
--_mtable-regex-PuppetManifest=resourceNameInArray////{tquit}

--_mtable-extend-PuppetManifest=resourceBody+comment
--_mtable-extend-PuppetManifest=resourceBody+ignoreWhiteSpace
--_mtable-regex-PuppetManifest=resourceBody/\{//{tenter=skipBlock}
# --_mtable-extend-PuppetManifest=resourceBody+ignoreWhiteSpace
#
# Next pattern is just for optimization.
#
--_mtable-regex-PuppetManifest=resourceBody/([^\/#{'";}<])//
--_mtable-regex-PuppetManifest=resourceBody/'//{tenter=ssliteral}
--_mtable-regex-PuppetManifest=resourceBody/"//{tenter=dsliteral}
--_mtable-regex-PuppetManifest=resourceBody/;//{tleave}{scope=pop}
--_mtable-regex-PuppetManifest=resourceBody/\}//{tleave}{_advanceTo=0start}{scope=pop}
--_mtable-regex-PuppetManifest=resourceBody/\{//{tenter=skipBlock}
--_mtable-regex-PuppetManifest=resourceBody/;//{tleave}{scope=pop}
--_mtable-regex-PuppetManifest=resourceBody/<<?\|//{tenter=skipCollector}
--_mtable-extend-PuppetManifest=resourceBody+comment
--_mtable-extend-PuppetManifest=resourceBody+any

--_mtable-extend-PuppetManifest=resourceArray+comment
Expand Down

0 comments on commit d80947a

Please sign in to comment.