Skip to content

Commit

Permalink
Add usage of BinarySearch for searching a word in the words list
Browse files Browse the repository at this point in the history
  • Loading branch information
ebellocchia committed Apr 20, 2020
1 parent df8fe17 commit ba23c0e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion bip_utils/bip39.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,11 @@ def GetWordIdx(self, word):
Returns:
int: Word index
"""
return self.m_words_list.index(word)
idx = utils.BinarySearch(self.m_words_list, word)
if idx == -1:
raise ValueError("Word %s is not existent in word list" % word)

return idx

def GetWordAtIdx(self, word_idx):
""" Get the word at the specified index.
Expand Down

0 comments on commit ba23c0e

Please sign in to comment.