Merge bitcoin/bitcoin#26707: clang-tidy: Fix performance-*move* warnings in headers

1308b837dc clang-tidy: Fix `performance-no-automatic-move` in headers (Hennadii Stepanov)
0a5dc030b9 clang-tidy: Fix `performance-move-const-arg` in headers (Hennadii Stepanov)

Pull request description:

  Split from bitcoin/bitcoin#26705 as was requested in https://github.com/bitcoin/bitcoin/pull/26705#issuecomment-1353293405.

  To test this PR, consider applying a diff as follows:
  ```diff
  --- a/src/.clang-tidy
  +++ b/src/.clang-tidy
  @@ -1,16 +1,7 @@
   Checks: '
   -*,
  -bugprone-argument-comment,
  -bugprone-use-after-move,
  -misc-unused-using-decls,
  -modernize-use-default-member-init,
  -modernize-use-nullptr,
  -performance-for-range-copy,
   performance-move-const-arg,
   performance-no-automatic-move,
  -performance-unnecessary-copy-initialization,
  -readability-redundant-declaration,
  -readability-redundant-string-init,
   '
   WarningsAsErrors: '
   bugprone-argument-comment,
  @@ -28,4 +19,4 @@ readability-redundant-string-init,
   CheckOptions:
    - key: performance-move-const-arg.CheckTriviallyCopyableMove
      value: false
  -HeaderFilterRegex: './qt'
  +HeaderFilterRegex: '.'
  ```

ACKs for top commit:
  fanquake:
    ACK 1308b837dc

Tree-SHA512: b7ef9a3e789846130ab4c3fd6fbe8d887bdbcd438e4cbc78e2b1ac01f819ae13d7f69c2a25f480bd36e3e7f58886a7d5a8609a3c3275c315e0697cd4010474bd
This commit is contained in:
MarcoFalke 2023-01-24 16:28:03 +01:00
commit 30f553d457
No known key found for this signature in database
GPG key ID: CE2B75697E69A548
2 changed files with 3 additions and 3 deletions

View file

@ -35,7 +35,7 @@ public:
// Allow path objects arguments for compatibility.
path(std::filesystem::path path) : std::filesystem::path::path(std::move(path)) {}
path& operator=(std::filesystem::path path) { std::filesystem::path::operator=(std::move(path)); return *this; }
path& operator/=(std::filesystem::path path) { std::filesystem::path::operator/=(std::move(path)); return *this; }
path& operator/=(std::filesystem::path path) { std::filesystem::path::operator/=(path); return *this; }
// Allow literal string arguments, which are safe as long as the literals are ASCII.
path(const char* c) : std::filesystem::path(c) {}

View file

@ -1378,7 +1378,7 @@ inline NodeRef<Key> Parse(Span<const char> in, const Ctx& ctx)
assert(constructed.size() == 1);
assert(constructed[0]->ScriptSize() == script_size);
if (in.size() > 0) return {};
const NodeRef<Key> tl_node = std::move(constructed.front());
NodeRef<Key> tl_node = std::move(constructed.front());
tl_node->DuplicateKeyCheck(ctx);
return tl_node;
}
@ -1813,7 +1813,7 @@ inline NodeRef<Key> DecodeScript(I& in, I last, const Ctx& ctx)
}
}
if (constructed.size() != 1) return {};
const NodeRef<Key> tl_node = std::move(constructed.front());
NodeRef<Key> tl_node = std::move(constructed.front());
tl_node->DuplicateKeyCheck(ctx);
// Note that due to how ComputeType works (only assign the type to the node if the
// subs' types are valid) this would fail if any node of tree is badly typed.