aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-10-15 19:03:49 +0800
committerGitHub <noreply@github.com>2018-10-15 19:03:49 +0800
commit0778fb2dfca49bd84d202f78e31730c4e930749f (patch)
treef219a3a7d32bbfa59015ea035102fe0069e0d761 /libsolidity
parentb2b845d6def4d28215c5d591589555bd8f4ea6ab (diff)
parent1ce9566e504f3ce14978a9df5e8b37b74e6f621e (diff)
downloaddexon-solidity-0778fb2dfca49bd84d202f78e31730c4e930749f.tar.gz
dexon-solidity-0778fb2dfca49bd84d202f78e31730c4e930749f.tar.zst
dexon-solidity-0778fb2dfca49bd84d202f78e31730c4e930749f.zip
Merge pull request #5208 from mestorlx/bug4156
[WIP] Bad identifier suggestion in certain cases
Diffstat (limited to 'libsolidity')
-rw-r--r--libsolidity/analysis/DeclarationContainer.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/libsolidity/analysis/DeclarationContainer.cpp b/libsolidity/analysis/DeclarationContainer.cpp
index 5f980788..cf12a49d 100644
--- a/libsolidity/analysis/DeclarationContainer.cpp
+++ b/libsolidity/analysis/DeclarationContainer.cpp
@@ -137,23 +137,23 @@ vector<Declaration const*> DeclarationContainer::resolveName(ASTString const& _n
vector<ASTString> DeclarationContainer::similarNames(ASTString const& _name) const
{
- static size_t const MAXIMUM_EDIT_DISTANCE = 2;
+
// because the function below has quadratic runtime - it will not magically improve once a better algorithm is discovered ;)
// since 80 is the suggested line length limit, we use 80^2 as length threshold
static size_t const MAXIMUM_LENGTH_THRESHOLD = 80 * 80;
vector<ASTString> similar;
-
+ size_t maximumEditDistance = _name.size() > 3 ? 2 : _name.size() / 2;
for (auto const& declaration: m_declarations)
{
string const& declarationName = declaration.first;
- if (stringWithinDistance(_name, declarationName, MAXIMUM_EDIT_DISTANCE, MAXIMUM_LENGTH_THRESHOLD))
+ if (stringWithinDistance(_name, declarationName, maximumEditDistance, MAXIMUM_LENGTH_THRESHOLD))
similar.push_back(declarationName);
}
for (auto const& declaration: m_invisibleDeclarations)
{
string const& declarationName = declaration.first;
- if (stringWithinDistance(_name, declarationName, MAXIMUM_EDIT_DISTANCE, MAXIMUM_LENGTH_THRESHOLD))
+ if (stringWithinDistance(_name, declarationName, maximumEditDistance, MAXIMUM_LENGTH_THRESHOLD))
similar.push_back(declarationName);
}