Skip to content

Commit 7bf42d4

Browse files
srawlinsCommit Queue
authored andcommitted
DAS levenshtein: Use lowerCamelCase for constant names
Change-Id: Iaa612fddbfc982ebd20910390ee613a43e256fab Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/458321 Auto-Submit: Samuel Rawlins <[email protected]> Commit-Queue: Keerti Parthasarathy <[email protected]> Reviewed-by: Keerti Parthasarathy <[email protected]>
1 parent 6655850 commit 7bf42d4

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

pkg/analysis_server/lib/src/services/correction/levenshtein.dart

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import 'dart:math' as math;
66

77
/// The value returned by [levenshtein] if the distance is determined
88
/// to be over the specified threshold.
9-
const int LEVENSHTEIN_MAX = 1 << 20;
9+
const int levenshteinMax = 1 << 20;
1010

11-
const int _MAX_VALUE = 1 << 10;
11+
const int _maxValue = 1 << 10;
1212

1313
/// Find the Levenshtein distance between two [String]s if it's less than or
1414
/// equal to a given threshold.
@@ -41,14 +41,14 @@ int levenshtein(
4141
// if one string is empty,
4242
// the edit distance is necessarily the length of the other
4343
if (sLength == 0) {
44-
return tLength <= threshold ? tLength : LEVENSHTEIN_MAX;
44+
return tLength <= threshold ? tLength : levenshteinMax;
4545
}
4646
if (tLength == 0) {
47-
return sLength <= threshold ? sLength : LEVENSHTEIN_MAX;
47+
return sLength <= threshold ? sLength : levenshteinMax;
4848
}
4949
// the distance can never be less than abs(s_len - t_len)
5050
if ((sLength - tLength).abs() > threshold) {
51-
return LEVENSHTEIN_MAX;
51+
return levenshteinMax;
5252
}
5353

5454
// swap the two strings to consume less memory
@@ -75,8 +75,8 @@ int levenshtein(
7575

7676
// these fills ensure that the value above the rightmost entry of our
7777
// stripe will be ignored in following loop iterations
78-
_setRange(p, boundary, p.length, _MAX_VALUE);
79-
_setRange(d, 0, d.length, _MAX_VALUE);
78+
_setRange(p, boundary, p.length, _maxValue);
79+
_setRange(d, 0, d.length, _maxValue);
8080

8181
// iterates through t
8282
for (var j = 1; j <= tLength; j++) {
@@ -90,12 +90,12 @@ int levenshtein(
9090

9191
// the stripe may lead off of the table if s and t are of different sizes
9292
if (min > max) {
93-
return LEVENSHTEIN_MAX;
93+
return levenshteinMax;
9494
}
9595

9696
// ignore entry left of leftmost
9797
if (min > 1) {
98-
d[min - 1] = _MAX_VALUE;
98+
d[min - 1] = _maxValue;
9999
}
100100

101101
// iterates through [min, max] in s
@@ -121,7 +121,7 @@ int levenshtein(
121121
return p[sLength];
122122
}
123123

124-
return LEVENSHTEIN_MAX;
124+
return levenshteinMax;
125125
}
126126

127127
void _setRange(List<int> a, int start, int end, int value) {

pkg/analysis_server/test/services/correction/levenshtein_test.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ class LevenshteinTest {
2525
}
2626

2727
void test_different_overThreshold() {
28-
expect(levenshtein('', 'abcde', 2), LEVENSHTEIN_MAX);
29-
expect(levenshtein('abcde', '', 2), LEVENSHTEIN_MAX);
28+
expect(levenshtein('', 'abcde', 2), levenshteinMax);
29+
expect(levenshtein('abcde', '', 2), levenshteinMax);
3030
}
3131

3232
void test_different_overThreshold_length() {
33-
expect(levenshtein('a', 'abcdefgh', 5), LEVENSHTEIN_MAX);
34-
expect(levenshtein('abcdefgh', 'a', 5), LEVENSHTEIN_MAX);
33+
expect(levenshtein('a', 'abcdefgh', 5), levenshteinMax);
34+
expect(levenshtein('abcdefgh', 'a', 5), levenshteinMax);
3535
}
3636

3737
void test_different_underThreshold() {

0 commit comments

Comments
 (0)