ITADN

Implication that padding zeroes would be copied seems to be wrong in multiple ways

#67Closedjarikirma 创建于 2023-01-03
J
jarikirmacommented
https://github.com/lemire/Code-used-on-Daniel-Lemire-s-blog/blob/ef75e1d8b3027dca18b964cd258e135f28a0345e/2022/12/29/protocol.cpp#L231-L240 I'm not really a C++ coder, but first of all: `strlen` explicitly strips length beyond the first `'\0'`, which prevents testing this code with non-zero bytes after one. Secondly, it would seem that even if `strlen` is replaced with 8 (... which breaks the half of tests which actually relies on getting the length this way), those bytes are not copied - are they just by chance uninitialised zero generated by padding? I found this out while trying out a relatively simple nul-terminated string to zero-padded `uin64_t` with a fast path under assumption that only strings which cross page boundaries need byte-accurate reads and that padding can be performed by applying Hacker's Delight algorithm for finding the first zero byte.
关闭于 2023-01-03 3 条评论