From 75bac1e5144f372d693e2e276fb0084273a26880 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 1 May 2020 10:12:45 -0400 Subject: [PATCH] core/hw/rsa: Take std::vector instances by value Allows us to std::move them and allow calling code to eliminate copies from occurring entirely. --- src/core/hw/rsa/rsa.cpp | 2 +- src/core/hw/rsa/rsa.h | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/core/hw/rsa/rsa.cpp b/src/core/hw/rsa/rsa.cpp index 8f2c93243..a349cbf37 100644 --- a/src/core/hw/rsa/rsa.cpp +++ b/src/core/hw/rsa/rsa.cpp @@ -74,7 +74,7 @@ void InitSlots() { std::vector exponent(256); file.ReadArray(exponent.data(), exponent.size()); - rsa_slots[0] = RsaSlot(exponent, modulus); + rsa_slots[0] = RsaSlot(std::move(exponent), std::move(modulus)); // TODO(B3N30): Initalize the other slots. But since they aren't used at all, we can skip them // for now } diff --git a/src/core/hw/rsa/rsa.h b/src/core/hw/rsa/rsa.h index 869d98d89..6385ed783 100644 --- a/src/core/hw/rsa/rsa.h +++ b/src/core/hw/rsa/rsa.h @@ -11,9 +11,9 @@ namespace HW::RSA { class RsaSlot { public: - RsaSlot() : init(false) {} - RsaSlot(const std::vector& exponent, const std::vector& modulus) - : init(true), exponent(exponent), modulus(modulus) {} + RsaSlot() = default; + RsaSlot(std::vector exponent, std::vector modulus) + : init(true), exponent(std::move(exponent)), modulus(std::move(modulus)) {} std::vector GetSignature(const std::vector& message); operator bool() const { @@ -22,7 +22,7 @@ public: } private: - bool init; + bool init = false; std::vector exponent; std::vector modulus; };