Skip to main content
Commonmark migration
Source Link

###Unnecessary recursion###

Unnecessary recursion

I feel that free_bucket() should be made iterative instead of recursive. The problem with it being recursive is that the length of the list being freed is unbounded. So for example if you had 1 million entries in the list, you could end up overflowing your stack by recursing 1 million times. It is simple enough to use a for loop like the one in HashTable_remove() to do the same thing.

###Unnecessary recursion###

I feel that free_bucket() should be made iterative instead of recursive. The problem with it being recursive is that the length of the list being freed is unbounded. So for example if you had 1 million entries in the list, you could end up overflowing your stack by recursing 1 million times. It is simple enough to use a for loop like the one in HashTable_remove() to do the same thing.

Unnecessary recursion

I feel that free_bucket() should be made iterative instead of recursive. The problem with it being recursive is that the length of the list being freed is unbounded. So for example if you had 1 million entries in the list, you could end up overflowing your stack by recursing 1 million times. It is simple enough to use a for loop like the one in HashTable_remove() to do the same thing.

Source Link
JS1
  • 28.9k
  • 3
  • 42
  • 83

###Unnecessary recursion###

I feel that free_bucket() should be made iterative instead of recursive. The problem with it being recursive is that the length of the list being freed is unbounded. So for example if you had 1 million entries in the list, you could end up overflowing your stack by recursing 1 million times. It is simple enough to use a for loop like the one in HashTable_remove() to do the same thing.