Isn't the following piece of code does the same lookup in table three times:
    
    
    if counts.contains(word_hash):
      counts[word_hash] += 1
    elif counts.len < counters:
      counts[word_hash] = 1
    else:
    

You can do a single lookup by leveraging **withValue**

[https://nim-lang.org/docs/tables.html#withValue.t,Table%5BA,B%5D,A,untyped,untyped,untyped](https://nim-lang.org/docs/tables.html#withValue.t,Table%5BA,B%5D,A,untyped,untyped,untyped)

Reply via email to