Minor changes.

This commit is contained in:
chriseth 2018-02-09 17:45:45 +01:00 committed by Alex Beregszaszi
parent 8a491c77ba
commit dc0a25f1cd
2 changed files with 8 additions and 6 deletions

View File

@ -34,7 +34,8 @@ bool dev::stringWithinDistance(string const& _str1, string const& _str2, size_t
if (_str1 == _str2)
return true;
size_t n1 = _str1.size(), n2 = _str2.size();
size_t n1 = _str1.size();
size_t n2 = _str2.size();
size_t distance = stringDistance(_str1, _str2);
// if distance is not greater than _maxDistance, and distance is strictly less than length of both names, they can be considered similar
@ -44,7 +45,8 @@ bool dev::stringWithinDistance(string const& _str1, string const& _str2, size_t
size_t dev::stringDistance(string const& _str1, string const& _str2)
{
size_t n1 = _str1.size(), n2 = _str2.size();
size_t n1 = _str1.size();
size_t n2 = _str2.size();
// Optimize by storing only last 2 rows and current row. So first index is considered modulo 3
vector<vector<size_t>> dp(3, vector<size_t>(n2 + 1));
@ -73,7 +75,8 @@ size_t dev::stringDistance(string const& _str1, string const& _str2)
return dp[n1 % 3][n2];
}
string dev::quotedAlternativesList(vector<string> const& suggestions) {
string dev::quotedAlternativesList(vector<string> const& suggestions)
{
if (suggestions.empty())
return "";
if (suggestions.size() == 1)

View File

@ -59,15 +59,14 @@ public:
Declaration const* conflictingDeclaration(Declaration const& _declaration, ASTString const* _name = nullptr) const;
/// @returns existing declaration names similar to @a _name.
/// Searches this and all parent containers.
std::vector<ASTString> similarNames(ASTString const& _name) const;
private:
ASTNode const* m_enclosingNode;
DeclarationContainer const* m_enclosingContainer;
std::map<ASTString, std::vector<Declaration const*>> m_declarations;
std::map<ASTString, std::vector<Declaration const*>> m_invisibleDeclarations;
};
}