From a4f777b84dbb6ef1f5240246ef3a27570e0dd9f4 Mon Sep 17 00:00:00 2001 From: Pavel Kryukov Date: Thu, 11 Jun 2020 10:26:20 +0300 Subject: [PATCH] Move std::ostringstream to std::string --- simulator/func_sim/operation.h | 6 +++--- simulator/infra/config/t/unit_test.cpp | 2 +- simulator/infra/t/unit_test.cpp | 16 ++++++++-------- simulator/memory/hierarchied_memory.cpp | 2 +- simulator/memory/memory.cpp | 2 +- simulator/memory/plain_memory.cpp | 2 +- simulator/mips/mips_instr.cpp | 4 ++-- simulator/modules/fetch/bpu/bpu.cpp | 2 +- 8 files changed, 18 insertions(+), 18 deletions(-) diff --git a/simulator/func_sim/operation.h b/simulator/func_sim/operation.h index 97716cb34..94246d390 100644 --- a/simulator/func_sim/operation.h +++ b/simulator/func_sim/operation.h @@ -65,7 +65,7 @@ std::string print_immediate( Imm type, T value) case Imm::SHIFT: oss << ", " << std::dec << value; break; case Imm::NO: break; } - return oss.str(); + return std::move( oss).str(); } class Operation @@ -245,7 +245,7 @@ std::string BaseInstruction::generate_disasm() const oss << " $" << (this->print_dst.test( 0) ? get_dst( 0) : get_src( 1)) << print_immediate( Imm::ADDR, this->get_v_imm()) << "($" << get_src( 0) << ")" << std::dec; - return oss.str(); + return std::move( oss).str(); } for ( size_t i = 0; i < MAX_DST_NUM; i++) @@ -258,7 +258,7 @@ std::string BaseInstruction::generate_disasm() const oss << ( i > 0 ? ", $" : " $") << get_src( i); oss << print_immediate( this->imm_print_type, this->get_v_imm()); - return oss.str(); + return std::move( oss).str(); } template diff --git a/simulator/infra/config/t/unit_test.cpp b/simulator/infra/config/t/unit_test.cpp index 75207f5ff..141edfefd 100644 --- a/simulator/infra/config/t/unit_test.cpp +++ b/simulator/infra/config/t/unit_test.cpp @@ -28,7 +28,7 @@ std::string wrap_shift_operator(const T& value) { std::ostringstream oss; oss << value; - return oss.str(); + return std::move( oss).str(); } static void handleArgs( const std::vector& argv) diff --git a/simulator/infra/t/unit_test.cpp b/simulator/infra/t/unit_test.cpp index c834c41cb..904b5efb6 100644 --- a/simulator/infra/t/unit_test.cpp +++ b/simulator/infra/t/unit_test.cpp @@ -281,28 +281,28 @@ static std::string uint128_to_hex_string(uint128 number) { std::ostringstream out; out << std::hex << std::uppercase << number; - return out.str(); + return std::move( out).str(); } static std::string uint128_to_hex_showbase_string(uint128 number) { std::ostringstream out; out << std::showbase << std::hex << std::uppercase << number; - return out.str(); + return std::move( out).str(); } static std::string uint128_to_dec_string(uint128 number) { - std::ostringstream out; - out << number; - return out.str(); + std::ostringstream out; + out << number; + return std::move( out).str(); } static std::string uint128_to_oct_string(uint128 number) { - std::ostringstream out; - out << std::oct << number; - return out.str(); + std::ostringstream out; + out << std::oct << number; + return std::move( out).str(); } static std::string str_toupper(std::string s) { diff --git a/simulator/memory/hierarchied_memory.cpp b/simulator/memory/hierarchied_memory.cpp index 2ef712bff..f4026d261 100644 --- a/simulator/memory/hierarchied_memory.cpp +++ b/simulator/memory/hierarchied_memory.cpp @@ -171,7 +171,7 @@ std::string HierarchiedMemory::dump() const oss << "addr 0x" << get_addr( set_it, page_it, byte_it) << ": data 0x" << uint32( *byte_it) << std::endl; - return oss.str(); + return std::move( oss).str(); } Addr HierarchiedMemory::get_addr(const Mem::const_iterator& set_it, const Set::const_iterator& page_it, const Page::const_iterator& byte_it) const noexcept diff --git a/simulator/memory/memory.cpp b/simulator/memory/memory.cpp index b1f34c936..1779e53f2 100644 --- a/simulator/memory/memory.cpp +++ b/simulator/memory/memory.cpp @@ -25,7 +25,7 @@ std::string FuncMemoryOutOfRange::generate_string( Addr addr, Addr mask) { std::ostringstream oss; oss << "address: 0x" << std::hex << addr << "; max address: 0x" << mask; - return oss.str(); + return std::move( oss).str(); } // Write explicitly to solve code coverage issues diff --git a/simulator/memory/plain_memory.cpp b/simulator/memory/plain_memory.cpp index bef742923..9dde9b848 100644 --- a/simulator/memory/plain_memory.cpp +++ b/simulator/memory/plain_memory.cpp @@ -71,7 +71,7 @@ std::string PlainMemory::dump() const oss << "addr 0x" << std::distance(arena.begin(), it) << ": data 0x" << uint32( *it) << std::endl; - return oss.str(); + return std::move( oss).str(); } size_t PlainMemory::strlen( Addr addr) const diff --git a/simulator/mips/mips_instr.cpp b/simulator/mips/mips_instr.cpp index 1b20a35b9..16d983100 100644 --- a/simulator/mips/mips_instr.cpp +++ b/simulator/mips/mips_instr.cpp @@ -880,7 +880,7 @@ std::string BaseMIPSInstr::string_dump() const { std::ostringstream oss; this->dump_content( oss, get_disasm()); - return oss.str(); + return std::move( oss).str(); } template @@ -891,7 +891,7 @@ std::string BaseMIPSInstr::bytes_dump() const const auto& bytes = endian == std::endian::little ? unpack_array( raw) : unpack_array( raw); for ( const auto& b : bytes) oss << " 0x" << std::setfill( '0') << std::setw( 2) << static_cast( b); - return oss.str(); + return std::move( oss).str(); } template diff --git a/simulator/modules/fetch/bpu/bpu.cpp b/simulator/modules/fetch/bpu/bpu.cpp index 20cd9ccf0..2ea590e4a 100644 --- a/simulator/modules/fetch/bpu/bpu.cpp +++ b/simulator/modules/fetch/bpu/bpu.cpp @@ -139,7 +139,7 @@ class BPFactory { out << "Supported branch prediction modes:" << std::endl; for ( const auto& map_name : map) out << "\t" << map_name.first << std::endl; - return out.str(); + return std::move( out).str(); } public: