Skip to content

Commit e9cfe3c

Browse files
committed
suggestion_list: convert strings to lists before calculation
Replicates graphql/graphql-js@268888b
1 parent f7dbcfb commit e9cfe3c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/graphql/pyutils/suggestion_list.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from array import array
12
from typing import Collection, Optional, List
23

34
__all__ = ["suggestion_list"]
@@ -37,12 +38,15 @@ class LexicalDistance:
3738

3839
_input: str
3940
_input_lower_case: str
41+
_input_list = List[int]
4042
_rows: List[List[int]]
4143

4244
def __init__(self, input_: str):
4345
self._input = input_
4446
self._input_lower_case = input_.lower()
4547
row_size = len(input_) + 1
48+
self._input_list = list(map(ord, self._input_lower_case))
49+
4650
self._rows = [[0] * row_size, [0] * row_size, [0] * row_size]
4751

4852
def measure(self, option: str, threshold: int) -> Optional[int]:
@@ -55,7 +59,7 @@ def measure(self, option: str, threshold: int) -> Optional[int]:
5559
if self._input_lower_case == option_lower_case:
5660
return 1
5761

58-
a, b = option_lower_case, self._input_lower_case
62+
a, b = list(map(ord, option_lower_case)), self._input_list
5963
a_len, b_len = len(a), len(b)
6064
if a_len < b_len:
6165
a, b = b, a

0 commit comments

Comments
 (0)