https://bugs.documentfoundation.org/show_bug.cgi?id=163691

Mike Kaganski <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Use std::copy() instead of  |Use std::copy() instead of
                   |memcpy()                    |memcpy() (see also comment
                   |                            |25)

--- Comment #25 from Mike Kaganski <[email protected]> ---
Note that the idea is not to replace every occurrence of memcpy with std::copy.

memcpy is a low-level memory copy utility; it is most efficient in what it is
intended for: low-level memory copy. It should stay where it is reasonable.

How to tell? One diagnostic is, when you have to use reinterpret_cast to
replace memcpy with std::copy. As soon as you do that, you effectively try to
disguise a genuine low-level copy operation into something more high-level.
This is NOT needed.

The end result MUST be an improvement over the old code, not a "replacement
just for the sake of replacement". There are plenty of improvements possible,
like improved readability by using object size implicitly (note that wherever
you need to use "iterator + length" in std::copy, you better use copy_n) and
safety (using iterators often gives runtime out-of-bounds checks in debug
builds). If your change doesn't provide any upside, please avoid that.

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to