Details
Details
- Reviewers
Bigcheese nikic - Commits
- rGd9b3a9442530: [NFC] Change strcpy to std::copy
Diff Detail
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/lib/Object/COFFImportFile.cpp | ||
---|---|---|
89–90 | This isn't really a sensible way to use strncpy -- in fact, I'm pretty sure that this is buggy and should be S.size() + 1, otherwise we're not copying the trailing null byte, which is important in this context. Explicitly specifying the length does make sense (as we already know it here), but in that case we should just use memcpy, or, to make it more idiomatic for C++, std::copy. |
Comment Actions
Generated assembly for strcpy is smaller than that for std::copy, but there is 2 calls in std::copy and 3 calls in strcpy. Could not evaluate performance by just looking at assemblies.
Comment Actions
LGTM. Assuming you don't have commit access, can you tell me the Name <email> to use for the commit?
This isn't really a sensible way to use strncpy -- in fact, I'm pretty sure that this is buggy and should be S.size() + 1, otherwise we're not copying the trailing null byte, which is important in this context.
Explicitly specifying the length does make sense (as we already know it here), but in that case we should just use memcpy, or, to make it more idiomatic for C++, std::copy.