perf: better keyword time complexity
This commit is contained in:
parent
01949f136a
commit
a5680bb3bc
|
@ -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(
|
||||||
|
|
|
@ -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
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -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"
|
||||||
|
|
|
@ -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
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user