Skip to content

Commit

Permalink
Move std::ostringstream to std::string
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelkryukov committed Jun 11, 2020
1 parent 7c4ae68 commit a4f777b
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 18 deletions.
6 changes: 3 additions & 3 deletions simulator/func_sim/operation.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -245,7 +245,7 @@ std::string BaseInstruction<T, R>::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++)
Expand All @@ -258,7 +258,7 @@ std::string BaseInstruction<T, R>::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<typename T, typename R>
Expand Down
2 changes: 1 addition & 1 deletion simulator/infra/config/t/unit_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<const char*>& argv)
Expand Down
16 changes: 8 additions & 8 deletions simulator/infra/t/unit_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion simulator/memory/hierarchied_memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion simulator/memory/memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion simulator/memory/plain_memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions simulator/mips/mips_instr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ std::string BaseMIPSInstr<R>::string_dump() const
{
std::ostringstream oss;
this->dump_content( oss, get_disasm());
return oss.str();
return std::move( oss).str();
}

template<typename R>
Expand All @@ -891,7 +891,7 @@ std::string BaseMIPSInstr<R>::bytes_dump() const
const auto& bytes = endian == std::endian::little ? unpack_array<uint32, std::endian::little>( raw) : unpack_array<uint32, std::endian::big>( raw);
for ( const auto& b : bytes)
oss << " 0x" << std::setfill( '0') << std::setw( 2) << static_cast<uint16>( b);
return oss.str();
return std::move( oss).str();
}

template<typename R>
Expand Down
2 changes: 1 addition & 1 deletion simulator/modules/fetch/bpu/bpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit a4f777b

Please sign in to comment.