Skip to content

Conversation

@AmrDeveloper
Copy link
Member

Remove redundant copy parameter and move it

from explicit OwningMemoryBlock(MemoryBlock M) : M(M) {}

to explicit OwningMemoryBlock(MemoryBlock M) : M(std::move(m)) {}

Fixes: #95640

@llvmbot
Copy link
Member

llvmbot commented Sep 24, 2024

@llvm/pr-subscribers-llvm-support

Author: Amr Hesham (AmrDeveloper)

Changes

Remove redundant copy parameter and move it

from explicit OwningMemoryBlock(MemoryBlock M) : M(M) {}

to explicit OwningMemoryBlock(MemoryBlock M) : M(std::move(m)) {}

Fixes: #95640


Full diff: https://github.com/llvm/llvm-project/pull/109859.diff

1 Files Affected:

  • (modified) llvm/include/llvm/Support/Memory.h (+1-1)
diff --git a/llvm/include/llvm/Support/Memory.h b/llvm/include/llvm/Support/Memory.h
index d7d60371d315f0..c02a3cc14dc7de 100644
--- a/llvm/include/llvm/Support/Memory.h
+++ b/llvm/include/llvm/Support/Memory.h
@@ -137,7 +137,7 @@ namespace sys {
   class OwningMemoryBlock {
   public:
     OwningMemoryBlock() = default;
-    explicit OwningMemoryBlock(MemoryBlock M) : M(M) {}
+    explicit OwningMemoryBlock(MemoryBlock M) : M(std::move(M)) {}
     OwningMemoryBlock(OwningMemoryBlock &&Other) {
       M = Other.M;
       Other.M = MemoryBlock();

Copy link
Collaborator

@DavidSpickett DavidSpickett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@AmrDeveloper AmrDeveloper merged commit dd63ede into llvm:main Oct 15, 2024
DanielCChen pushed a commit to DanielCChen/llvm-project that referenced this pull request Oct 16, 2024
Remove redundant copy parameter and move it

from `explicit OwningMemoryBlock(MemoryBlock M) : M(M) {}`

to `explicit OwningMemoryBlock(MemoryBlock M) : M(std::move(m)) {}`

Fixes: llvm#95640
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

llvm/include/llvm/Support/Memory.h:140: Pointless copy ?

3 participants