From cbe1ec51dff97903948a902f633e68b466d49fbc Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 21 Jan 2017 22:11:49 -0500 Subject: [PATCH] DSPAssembler: Make AssembleFile take a std::string File paths passed to it would have been implicitly converted to std::strings prior to this function being reached, so it gets rid of some string churn. It also makes it safer since nullptr can't be passed in. --- Source/Core/Core/DSP/DSPAssembler.cpp | 14 +++++++------- Source/Core/Core/DSP/DSPAssembler.h | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Source/Core/Core/DSP/DSPAssembler.cpp b/Source/Core/Core/DSP/DSPAssembler.cpp index 820850c3fc..327bf49f6c 100644 --- a/Source/Core/Core/DSP/DSPAssembler.cpp +++ b/Source/Core/Core/DSP/DSPAssembler.cpp @@ -63,11 +63,11 @@ bool DSPAssembler::Assemble(const std::string& text, std::vector& code, { if (line_numbers) line_numbers->clear(); - const char* fname = "tmp.asm"; - if (!File::WriteStringToFile(text, fname)) + const std::string file_name = "tmp.asm"; + if (!File::WriteStringToFile(text, file_name)) return false; InitPass(1); - if (!AssembleFile(fname, 1)) + if (!AssembleFile(file_name, 1)) return false; // We now have the size of the output buffer @@ -83,7 +83,7 @@ bool DSPAssembler::Assemble(const std::string& text, std::vector& code, return false; InitPass(2); - if (!AssembleFile(fname, 2)) + if (!AssembleFile(file_name, 2)) return false; code.resize(m_totalSize); @@ -764,16 +764,16 @@ void DSPAssembler::InitPass(int pass) segment_addr[SEGMENT_OVERLAY] = 0; } -bool DSPAssembler::AssembleFile(const char* fname, int pass) +bool DSPAssembler::AssembleFile(const std::string& file_path, int pass) { int disable_text = 0; // modified by Hermes std::ifstream fsrc; - OpenFStream(fsrc, fname, std::ios_base::in); + OpenFStream(fsrc, file_path, std::ios_base::in); if (fsrc.fail()) { - std::cerr << "Cannot open file " << fname << std::endl; + std::cerr << "Cannot open file " << file_path << std::endl; return false; } diff --git a/Source/Core/Core/DSP/DSPAssembler.h b/Source/Core/Core/DSP/DSPAssembler.h index 383451feea..233100fc31 100644 --- a/Source/Core/Core/DSP/DSPAssembler.h +++ b/Source/Core/Core/DSP/DSPAssembler.h @@ -84,7 +84,7 @@ private: u32 GetParams(char* parstr, param_t* par); void InitPass(int pass); - bool AssembleFile(const char* fname, int pass); + bool AssembleFile(const std::string& file_path, int pass); void ShowError(err_t err_code, const char* extra_info = nullptr); // void ShowWarning(err_t err_code, const char *extra_info = nullptr);