perf: better keyword time complexity
All checks were successful
build / build (push) Successful in 2m27s
build / build (pull_request) Successful in 2m26s

This commit is contained in:
张泊明518370910136 2025-03-05 02:33:10 -05:00
parent 01949f136a
commit a5680bb3bc
GPG Key ID: D47306D7062CDA9D
6 changed files with 69 additions and 73 deletions

View File

@ -102,19 +102,15 @@ def get_executor_with(
def fix_keyword( def fix_keyword(
keyword_config: task.ParserKeyword, keyword_parser: result.Parser keyword_config: task.ParserKeyword, keyword_parser: result.Parser
) -> None: ) -> None:
keyword_weight: List[result.KeywordConfig] = [] score_groups: Dict[int, List[str]] = {}
unique_weight = list(set(keyword_config.weight)) for keyword, score in zip(keyword_config.keyword, keyword_config.weight):
for score in unique_weight: score_groups.setdefault(score, []).append(keyword)
keyword_weight.append(result.KeywordConfig(keywords=[], score=score)) keyword_parser.with_ = result.KeywordMatchConfig(
matches=[
for idx, score in enumerate(unique_weight): result.KeywordConfig(keywords=keywords, score=score)
for idx_, score_ in enumerate(keyword_config.weight): for score, keywords in score_groups.items()
if score == score_: ]
keyword_weight[idx].keywords.append(keyword_config.keyword[idx_]) )
else:
continue
keyword_parser.with_ = result.KeywordMatchConfig(matches=keyword_weight)
def fix_result_detail( def fix_result_detail(

View File

@ -249,17 +249,17 @@
"name": "keyword", "name": "keyword",
"with": { "with": {
"matches": [ "matches": [
{
"keywords": [
"recommended"
],
"score": 10
},
{ {
"keywords": [ "keywords": [
"max" "max"
], ],
"score": 20 "score": 20
},
{
"keywords": [
"recommended"
],
"score": 10
} }
] ]
} }
@ -349,20 +349,6 @@
"name": "clangtidy", "name": "clangtidy",
"with": { "with": {
"matches": [ "matches": [
{
"keywords": [
"readability-function-size"
],
"score": 10
},
{
"keywords": [
"codequality-no-global-variables",
"codequality-no-header-guard",
"codequality-no-fflush-stdin"
],
"score": 20
},
{ {
"keywords": [ "keywords": [
"codequality-unchecked-malloc-result", "codequality-unchecked-malloc-result",
@ -381,6 +367,20 @@
], ],
"score": 5 "score": 5
}, },
{
"keywords": [
"codequality-no-global-variables",
"codequality-no-header-guard",
"codequality-no-fflush-stdin"
],
"score": 20
},
{
"keywords": [
"readability-function-size"
],
"score": 10
},
{ {
"keywords": [ "keywords": [
"readability-misleading-indentation" "readability-misleading-indentation"
@ -477,6 +477,12 @@
"name": "cppcheck", "name": "cppcheck",
"with": { "with": {
"matches": [ "matches": [
{
"keywords": [
"error"
],
"score": 15
},
{ {
"keywords": [ "keywords": [
"warning", "warning",
@ -485,12 +491,6 @@
"style" "style"
], ],
"score": 5 "score": 5
},
{
"keywords": [
"error"
],
"score": 15
} }
] ]
} }
@ -618,9 +618,9 @@
"matches": [ "matches": [
{ {
"keywords": [ "keywords": [
"build" "runtime"
], ],
"score": 10 "score": 5
}, },
{ {
"keywords": [ "keywords": [
@ -630,9 +630,9 @@
}, },
{ {
"keywords": [ "keywords": [
"runtime" "build"
], ],
"score": 5 "score": 10
} }
] ]
} }

View File

@ -77,20 +77,6 @@
"name": "clangtidy", "name": "clangtidy",
"with": { "with": {
"matches": [ "matches": [
{
"keywords": [
"readability-function-size"
],
"score": 10
},
{
"keywords": [
"codequality-no-global-variables",
"codequality-no-header-guard",
"codequality-no-fflush-stdin"
],
"score": 20
},
{ {
"keywords": [ "keywords": [
"codequality-unchecked-malloc-result", "codequality-unchecked-malloc-result",
@ -109,6 +95,20 @@
], ],
"score": 5 "score": 5
}, },
{
"keywords": [
"codequality-no-global-variables",
"codequality-no-header-guard",
"codequality-no-fflush-stdin"
],
"score": 20
},
{
"keywords": [
"readability-function-size"
],
"score": 10
},
{ {
"keywords": [ "keywords": [
"readability-misleading-indentation" "readability-misleading-indentation"

View File

@ -70,6 +70,12 @@
"name": "cppcheck", "name": "cppcheck",
"with": { "with": {
"matches": [ "matches": [
{
"keywords": [
"error"
],
"score": 15
},
{ {
"keywords": [ "keywords": [
"warning", "warning",
@ -78,12 +84,6 @@
"style" "style"
], ],
"score": 5 "score": 5
},
{
"keywords": [
"error"
],
"score": 15
} }
] ]
} }

View File

@ -71,9 +71,9 @@
"matches": [ "matches": [
{ {
"keywords": [ "keywords": [
"build" "runtime"
], ],
"score": 10 "score": 5
}, },
{ {
"keywords": [ "keywords": [
@ -83,9 +83,9 @@
}, },
{ {
"keywords": [ "keywords": [
"runtime" "build"
], ],
"score": 5 "score": 10
} }
] ]
} }

View File

@ -72,17 +72,17 @@
"name": "keyword", "name": "keyword",
"with": { "with": {
"matches": [ "matches": [
{
"keywords": [
"recommended"
],
"score": 10
},
{ {
"keywords": [ "keywords": [
"max" "max"
], ],
"score": 20 "score": 20
},
{
"keywords": [
"recommended"
],
"score": 10
} }
] ]
} }