Use std::istringstream or std::ostringstream instead of std::stringstream where possible.

This removes std::iostream from the inheritance chain, which reduces
overhead slightly.
This commit is contained in:
David Korth 2019-09-14 16:40:34 -04:00
parent 6e549bb668
commit c2dd2e8a2e
14 changed files with 20 additions and 20 deletions

View File

@ -147,7 +147,7 @@ void WaveFileWriter::AddStereoSamplesBE(const short* sample_data, u32 count, int
{
Stop();
file_index++;
std::stringstream filename;
std::ostringstream filename;
filename << File::GetUserPath(D_DUMPAUDIO_IDX) << basename << file_index << ".wav";
Start(filename.str(), sample_rate);
current_sample_rate = sample_rate;

View File

@ -104,7 +104,7 @@ std::vector<std::string> Watches::SaveToStrings() const
std::vector<std::string> watches;
for (const auto& watch : m_watches)
{
std::stringstream ss;
std::ostringstream ss;
ss << std::hex << watch.address << " " << watch.name;
watches.push_back(ss.str());
}

View File

@ -398,7 +398,7 @@ std::string JoinStrings(const std::vector<std::string>& strings, const std::stri
if (strings.empty())
return "";
std::stringstream res;
std::ostringstream res;
std::copy(strings.begin(), strings.end(),
std::ostream_iterator<std::string>(res, delimiter.c_str()));

View File

@ -307,7 +307,7 @@ static void RunSIBuffer(u64 user_data, s64 cycles_late)
s_com_csr.CHANNEL, request_length, expected_response_length, actual_response_length);
if (expected_response_length != actual_response_length)
{
std::stringstream ss;
std::ostringstream ss;
for (u8 b : request_copy)
{
ss << std::hex << std::setw(2) << std::setfill('0') << (int)b << ' ';

View File

@ -512,7 +512,7 @@ void BluetoothReal::LoadLinkKeys()
for (size_t i = 0; i < key_string.length(); i = i + 2)
{
int value;
std::stringstream(key_string.substr(i, 2)) >> std::hex >> value;
std::istringstream(key_string.substr(i, 2)) >> std::hex >> value;
key[pos++] = value;
}

View File

@ -18,7 +18,7 @@ namespace IOS::HLE::Device
{
static void GetVidPidFromDevicePath(const std::string& device_path, u16& vid, u16& pid)
{
std::stringstream stream{device_path};
std::istringstream stream{device_path};
std::string segment;
std::vector<std::string> list;
while (std::getline(stream, segment, '/'))

View File

@ -50,7 +50,7 @@ void MemoryWatcher::ParseLine(const std::string& line)
m_values[line] = 0;
m_addresses[line] = std::vector<u32>();
std::stringstream offsets(line);
std::istringstream offsets(line);
offsets >> std::hex;
u32 offset;
while (offsets >> offset)
@ -76,7 +76,7 @@ u32 MemoryWatcher::ChasePointer(const std::string& line)
std::string MemoryWatcher::ComposeMessages()
{
std::stringstream message_stream;
std::ostringstream message_stream;
message_stream << std::hex;
for (auto& entry : m_values)

View File

@ -185,7 +185,7 @@ std::string GetRTCDisplay()
const time_t current_time = CEXIIPL::GetEmulatedTime(CEXIIPL::UNIX_EPOCH);
const tm* const gm_time = gmtime(&current_time);
std::stringstream format_time;
std::ostringstream format_time;
format_time << std::put_time(gm_time, "Date/Time: %c\n");
return format_time.str();
}

View File

@ -37,7 +37,7 @@ BreakPoints::TBreakPointsStr BreakPoints::GetStrings() const
{
if (!bp.is_temporary)
{
std::stringstream ss;
std::ostringstream ss;
ss << std::hex << bp.address << " " << (bp.is_enabled ? "n" : "");
bp_strings.push_back(ss.str());
}
@ -130,7 +130,7 @@ MemChecks::TMemChecksStr MemChecks::GetStrings() const
TMemChecksStr mc_strings;
for (const TMemCheck& mc : m_mem_checks)
{
std::stringstream ss;
std::ostringstream ss;
ss << std::hex << mc.start_address;
ss << " " << (mc.is_ranged ? mc.end_address : mc.start_address) << " "
<< (mc.is_ranged ? "n" : "") << (mc.is_break_on_read ? "r" : "")

View File

@ -1193,7 +1193,7 @@ void LogGeneratedX86(size_t size, const PPCAnalyst::CodeBuffer& code_buffer, con
if (b->codeSize <= 250)
{
std::stringstream ss;
std::ostringstream ss;
ss << std::hex;
for (u8 i = 0; i <= b->codeSize; i++)
{

View File

@ -464,7 +464,7 @@ std::string FormatSize(u64 bytes)
// Don't need exact values, only 5 most significant digits
const double unit_size = std::pow(2, unit * 10);
std::stringstream ss;
std::ostringstream ss;
ss << std::fixed << std::setprecision(2);
ss << bytes / unit_size << ' ' << Common::GetStringT(unit_symbols[unit]);
return ss.str();

View File

@ -434,7 +434,7 @@ void PostProcessing::BlitFromTexture(const MathUtil::Rectangle<int>& dst,
std::string PostProcessing::GetUniformBufferHeader() const
{
std::stringstream ss;
std::ostringstream ss;
u32 unused_counter = 1;
if (g_ActiveConfig.backend_info.api_type == APIType::D3D)
ss << "cbuffer PSBlock : register(b0) {\n";
@ -493,7 +493,7 @@ std::string PostProcessing::GetUniformBufferHeader() const
std::string PostProcessing::GetHeader() const
{
std::stringstream ss;
std::ostringstream ss;
ss << GetUniformBufferHeader();
if (g_ActiveConfig.backend_info.api_type == APIType::D3D)
{
@ -602,7 +602,7 @@ void main(in float3 v_tex0_ : TEXCOORD0, out float4 ocol0_ : SV_Target)
bool PostProcessing::CompileVertexShader()
{
std::stringstream ss;
std::ostringstream ss;
ss << GetUniformBufferHeader();
if (g_ActiveConfig.backend_info.api_type == APIType::D3D)

View File

@ -1392,7 +1392,7 @@ std::string GenerateDecodingShader(TextureFormat format, TLUTFormat palette_form
if (!info)
return "";
std::stringstream ss;
std::ostringstream ss;
switch (palette_format)
{
case TLUTFormat::IA8:
@ -1414,7 +1414,7 @@ std::string GenerateDecodingShader(TextureFormat format, TLUTFormat palette_form
std::string GeneratePaletteConversionShader(TLUTFormat palette_format, APIType api_type)
{
std::stringstream ss;
std::ostringstream ss;
ss << R"(
int Convert3To8(int v)

View File

@ -768,12 +768,12 @@ void VertexManagerBase::OnEndFrame()
#if 0
{
std::stringstream ss;
std::ostringstream ss;
std::for_each(m_cpu_accesses_this_frame.begin(), m_cpu_accesses_this_frame.end(), [&ss](u32 idx) { ss << idx << ","; });
WARN_LOG(VIDEO, "CPU EFB accesses in last frame: %s", ss.str().c_str());
}
{
std::stringstream ss;
std::ostringstream ss;
std::for_each(m_scheduled_command_buffer_kicks.begin(), m_scheduled_command_buffer_kicks.end(), [&ss](u32 idx) { ss << idx << ","; });
WARN_LOG(VIDEO, "Scheduled command buffer kicks: %s", ss.str().c_str());
}