Merge addWithoutResize and rehashIfNeeded into one function.