Skip to content

Commit

Permalink
simplify traverse() in huffman_code()
Browse files Browse the repository at this point in the history
  • Loading branch information
ilanschnell committed May 11, 2021
1 parent 47021c4 commit ce09746
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions bitarray/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,9 +379,9 @@ def huff_tree(freq_map):
result = {}

def traverse(nd, prefix=bitarray(0, endian)):
if hasattr(nd, 'symbol'): # leaf
try: # leaf
result[nd.symbol] = prefix
else: # parent, so traverse each of the children
except AttributeError: # parent, so traverse each of the children
traverse(nd.child[0], prefix + bitarray([0]))
traverse(nd.child[1], prefix + bitarray([1]))

Expand Down

0 comments on commit ce09746

Please sign in to comment.