Skip to content

Commit

Permalink
PuppetManifest: optimize the way to handle whitespaces and string lit…
Browse files Browse the repository at this point in the history
…erals

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  46.45s user 15.58s system 99% cpu 1:02.12 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  4.48s user 1.01s system 99% cpu 5.498 total

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
  • Loading branch information
masatake committed Oct 9, 2018
1 parent 1e22d3b commit 78fe1fd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
24 changes: 12 additions & 12 deletions optlib/puppetManifest.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ static void initializePuppetManifestParser (const langType language CTAGS_ATTR_U
"^\\#",
"", "", "{tenter=comment_oneline}", NULL);
addLanguageTagMultiTableRegex (language, "main",
"^[ \t\n]",
"^[ \t\n]+",
"", "", "", NULL);
addLanguageTagMultiTableRegex (language, "main",
"^'",
Expand Down Expand Up @@ -108,7 +108,7 @@ static void initializePuppetManifestParser (const langType language CTAGS_ATTR_U
"^.",
"", "", "", NULL);
addLanguageTagMultiTableRegex (language, "ignoreWhiteSpace",
"^[ \t\n]",
"^[ \t\n]+",
"", "", "", NULL);
addLanguageTagMultiTableRegex (language, "end",
"^",
Expand All @@ -117,13 +117,13 @@ static void initializePuppetManifestParser (const langType language CTAGS_ATTR_U
"^",
"", "", "{tleave}{scope=pop}", NULL);
addLanguageTagMultiTableRegex (language, "ssliteral",
"^[^']",
"^[^']+",
"", "", "", NULL);
addLanguageTagMultiTableRegex (language, "ssliteral",
"^'",
"", "", "{tleave}", NULL);
addLanguageTagMultiTableRegex (language, "dsliteral",
"^[^\"]",
"^[^\"]+",
"", "", "", NULL);
addLanguageTagMultiTableRegex (language, "dsliteral",
"^\"",
Expand Down Expand Up @@ -183,7 +183,7 @@ static void initializePuppetManifestParser (const langType language CTAGS_ATTR_U
"^.",
"", "", "", NULL);
addLanguageTagMultiTableRegex (language, "block",
"^[ \t\n]",
"^[ \t\n]+",
"", "", "", NULL);
addLanguageTagMultiTableRegex (language, "block",
"^@?::[a-zA-Z0-9:_]+[ \t\n]*\\{",
Expand Down Expand Up @@ -249,7 +249,7 @@ static void initializePuppetManifestParser (const langType language CTAGS_ATTR_U
"^([a-z][_a-zA-Z0-9:]*)",
"\\1", "c", "{tenter=blockHead,endWithPop}{scope=push}", NULL);
addLanguageTagMultiTableRegex (language, "resourceBlock",
"^[ \t\n]",
"^[ \t\n]+",
"", "", "", NULL);
addLanguageTagMultiTableRegex (language, "resourceBlock",
"^\\}",
Expand Down Expand Up @@ -387,7 +387,7 @@ static void initializePuppetManifestParser (const langType language CTAGS_ATTR_U
"^\\#",
"", "", "{tenter=comment_oneline}", NULL);
addLanguageTagMultiTableRegex (language, "caseStart",
"^[ \t\n]",
"^[ \t\n]+",
"", "", "", NULL);
addLanguageTagMultiTableRegex (language, "caseStart",
"^\\{",
Expand All @@ -405,7 +405,7 @@ static void initializePuppetManifestParser (const langType language CTAGS_ATTR_U
"^\\#",
"", "", "{tenter=comment_oneline}", NULL);
addLanguageTagMultiTableRegex (language, "ifStart",
"^[ \t\n]",
"^[ \t\n]+",
"", "", "", NULL);
addLanguageTagMultiTableRegex (language, "ifStart",
"^'",
Expand All @@ -426,7 +426,7 @@ static void initializePuppetManifestParser (const langType language CTAGS_ATTR_U
"^\\#",
"", "", "{tenter=comment_oneline}", NULL);
addLanguageTagMultiTableRegex (language, "nodeStart",
"^[ \t\n]",
"^[ \t\n]+",
"", "", "", NULL);
addLanguageTagMultiTableRegex (language, "nodeStart",
"^'([^']+)'",
Expand Down Expand Up @@ -471,7 +471,7 @@ static void initializePuppetManifestParser (const langType language CTAGS_ATTR_U
"^",
"", "", "{tquit}", NULL);
addLanguageTagMultiTableRegex (language, "resourceBody",
"^([^/#{'\";}<])",
"^[^/#{'\";}<]+",
"", "", "", NULL);
addLanguageTagMultiTableRegex (language, "resourceBody",
"^'",
Expand Down Expand Up @@ -507,7 +507,7 @@ static void initializePuppetManifestParser (const langType language CTAGS_ATTR_U
"^\\#",
"", "", "{tenter=comment_oneline}", NULL);
addLanguageTagMultiTableRegex (language, "resourceArray",
"^[ \t\n]",
"^[ \t\n]+",
"", "", "", NULL);
addLanguageTagMultiTableRegex (language, "resourceArray",
"^'",
Expand Down Expand Up @@ -567,7 +567,7 @@ static void initializePuppetManifestParser (const langType language CTAGS_ATTR_U
"^\\#",
"", "", "{tenter=comment_oneline}", NULL);
addLanguageTagMultiTableRegex (language, "caseBlock",
"^[ \t\n]",
"^[ \t\n]+",
"", "", "", NULL);
addLanguageTagMultiTableRegex (language, "caseBlock",
"^'",
Expand Down
8 changes: 4 additions & 4 deletions optlib/puppetManifest.ctags
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@
--_mtable-regex-PuppetManifest=separator///{tleave}

--_mtable-regex-PuppetManifest=any/.//
--_mtable-regex-PuppetManifest=ignoreWhiteSpace/[ \t\n]//
--_mtable-regex-PuppetManifest=ignoreWhiteSpace/[ \t\n]+//
--_mtable-regex-PuppetManifest=end///{tleave}
--_mtable-regex-PuppetManifest=endWithPop///{tleave}{scope=pop}

--_mtable-regex-PuppetManifest=ssliteral/[^']//
--_mtable-regex-PuppetManifest=ssliteral/[^']+//
--_mtable-regex-PuppetManifest=ssliteral/'//{tleave}
--_mtable-regex-PuppetManifest=dsliteral/[^"]//
--_mtable-regex-PuppetManifest=dsliteral/[^"]+//
--_mtable-regex-PuppetManifest=dsliteral/"//{tleave}

#
Expand Down Expand Up @@ -241,7 +241,7 @@
#
# Next pattern is just for optimization.
#
--_mtable-regex-PuppetManifest=resourceBody/([^\/#{'";}<])//
--_mtable-regex-PuppetManifest=resourceBody/[^\/#{'";}<]+//
--_mtable-regex-PuppetManifest=resourceBody/'//{tenter=ssliteral}
--_mtable-regex-PuppetManifest=resourceBody/"//{tenter=dsliteral}
--_mtable-regex-PuppetManifest=resourceBody/\}//{tleave}{_advanceTo=0start}{scope=pop}
Expand Down

0 comments on commit 78fe1fd

Please sign in to comment.