CRC32 Calculation for Zero Filled Buffer/File
问题 If I want to calculate the CRC32 value for a large number of consecutive zero bytes, is there a constant time formula I can use given the length of the run of zeros? For example, if I know I have 1000 bytes all filled with zeros, is there a way to avoid a loop with 1000 iterations (just an example, actual number of zeros is unbounded for the sake of this question)? 回答1: You can compute the result of applying n zeros not in O(1) time, but in O(log n ) time. This is done in zlib's crc32_combine