segfault, resizing may move the buffer
only calculate sums if needed