From 78fe1fd382b380cf89659756d6406032872d8bbe Mon Sep 17 00:00:00 2001 From: Masatake YAMATO Date: Mon, 8 Oct 2018 23:28:43 +0900 Subject: [PATCH] PuppetManifest: optimize the way to handle whitespaces and string literals Releated to #1912. example.pp.zip submitted to #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 --- optlib/puppetManifest.c | 24 ++++++++++++------------ optlib/puppetManifest.ctags | 8 ++++---- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/optlib/puppetManifest.c b/optlib/puppetManifest.c index 5b5c92e6e5..19a331ff9e 100644 --- a/optlib/puppetManifest.c +++ b/optlib/puppetManifest.c @@ -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", "^'", @@ -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", "^", @@ -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", "^\"", @@ -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]*\\{", @@ -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", "^\\}", @@ -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", "^\\{", @@ -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", "^'", @@ -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", "^'([^']+)'", @@ -471,7 +471,7 @@ static void initializePuppetManifestParser (const langType language CTAGS_ATTR_U "^", "", "", "{tquit}", NULL); addLanguageTagMultiTableRegex (language, "resourceBody", - "^([^/#{'\";}<])", + "^[^/#{'\";}<]+", "", "", "", NULL); addLanguageTagMultiTableRegex (language, "resourceBody", "^'", @@ -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", "^'", @@ -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", "^'", diff --git a/optlib/puppetManifest.ctags b/optlib/puppetManifest.ctags index 4be66dfd35..36c56b880f 100644 --- a/optlib/puppetManifest.ctags +++ b/optlib/puppetManifest.ctags @@ -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} # @@ -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}