diff --git a/src/asmexception.h b/src/asmexception.h index 7789a9f..6e4ceef 100644 --- a/src/asmexception.h +++ b/src/asmexception.h @@ -81,7 +81,7 @@ class AsmException_FileError : public AsmException class AsmException_FileError_##a : public AsmException_FileError \ { \ public: \ - explicit AsmException_FileError_##a( const std::string filename ) \ + explicit AsmException_FileError_##a( const std::string& filename ) \ : AsmException_FileError( filename ) {} \ \ virtual ~AsmException_FileError_##a() {} \ @@ -120,13 +120,13 @@ class AsmException_SyntaxError : public AsmException { } - AsmException_SyntaxError( std::string line, int column ) + AsmException_SyntaxError( const std::string& line, int column ) : m_line( line ), m_column( column ) { } - AsmException_SyntaxError( std::string line, int column, std::string extra ) + AsmException_SyntaxError( const std::string& line, int column, const std::string& extra ) : m_line( line ), m_column( column ), m_extra( extra ) @@ -161,7 +161,7 @@ class AsmException_SyntaxError : public AsmException class AsmException_SyntaxError_##a : public AsmException_SyntaxError \ { \ public: \ - AsmException_SyntaxError_##a( std::string line, int column ) \ + AsmException_SyntaxError_##a( const std::string& line, int column ) \ : AsmException_SyntaxError( line, column ) {} \ \ virtual ~AsmException_SyntaxError_##a() {} \ @@ -174,7 +174,7 @@ public: \ class AsmException_SyntaxError_##a : public AsmException_SyntaxError \ { \ public: \ - AsmException_SyntaxError_##a( std::string line, int column, std::string extra ) \ + AsmException_SyntaxError_##a( const std::string& line, int column, const std::string& extra ) \ : AsmException_SyntaxError( line, column, extra ) {} \ \ virtual ~AsmException_SyntaxError_##a() {} \ @@ -270,7 +270,7 @@ class AsmException_AssembleError : public AsmException_SyntaxError virtual ~AsmException_AssembleError() {} - void SetString( std::string line ) { m_line = line; } + void SetString( const std::string& line ) { m_line = line; } void SetColumn( int column ) { m_column = column; } virtual const char* Message() const @@ -309,7 +309,7 @@ class AsmException_UserError : public AsmException_SyntaxError { public: - AsmException_UserError( std::string line, int column, std::string message ) + AsmException_UserError( const std::string& line, int column, const std::string& message ) : AsmException_SyntaxError( line, column ), m_message( message ) { diff --git a/src/commands.cpp b/src/commands.cpp index bb3bd0f..42a8b8c 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -164,21 +164,17 @@ template class Argument // No value was available (i.e. the end of the parameters) StateMissing }; - Argument(string line, int column, State state) : + Argument(const string& line, int column, State state) : m_line(line), m_column(column), m_state(state) { } - Argument(string line, int column, T value) : + Argument(const string& line, int column, const T& value) : m_line(line), m_column(column), m_state(StateFound), m_value(value) { } Argument(const Argument& that) : m_line(that.m_line), m_column(that.m_column), m_state(that.m_state), m_value(that.m_value) { - m_line = that.m_line; - m_column = that.m_column; - m_state = that.m_state; - m_value = that.m_value; } // Is a value available? bool Found() const @@ -226,7 +222,7 @@ template class Argument } // Set a default value for optional parameters. // This is overloaded for strings below. - Argument& Default(T value) + Argument& Default(const T& value) { if ( !Found() ) { @@ -265,7 +261,7 @@ typedef Argument DoubleArg; typedef Argument StringArg; typedef Argument ValueArg; -template<> StringArg& StringArg::Default(string value) +template<> StringArg& StringArg::Default(const string& value) { if ( !Found() ) { @@ -1218,12 +1214,12 @@ void LineParser::HandleSave() if ( !objFile ) { - throw AsmException_FileError_OpenObj( saveFile.c_str() ); + throw AsmException_FileError_OpenObj( saveFile ); } if ( !objFile.write( reinterpret_cast< const char* >( ObjectCode::Instance().GetAddr( start ) ), end - start ) ) { - throw AsmException_FileError_WriteObj( saveFile.c_str() ); + throw AsmException_FileError_WriteObj( saveFile ); } objFile.close(); diff --git a/src/lineparser.cpp b/src/lineparser.cpp index 59a7859..05494ed 100644 --- a/src/lineparser.cpp +++ b/src/lineparser.cpp @@ -42,7 +42,7 @@ using namespace std; Constructor for LineParser */ /*************************************************************************************************/ -LineParser::LineParser( SourceCode* sourceCode, string line ) +LineParser::LineParser( SourceCode* sourceCode, const string& line ) : m_sourceCode( sourceCode ), m_line( line ), m_column( 0 ) @@ -76,7 +76,7 @@ LineParser::~LineParser() Process one line of the file */ /*************************************************************************************************/ -void LineParser::Process( string line ) +void LineParser::Process( const string& line ) { m_line = line; m_column = 0; diff --git a/src/lineparser.h b/src/lineparser.h index 78fbc1d..e1c0d0e 100644 --- a/src/lineparser.h +++ b/src/lineparser.h @@ -34,13 +34,13 @@ class LineParser // Constructor/destructor - LineParser( SourceCode* sourceCode, std::string line ); + LineParser( SourceCode* sourceCode, const std::string& line ); LineParser( SourceCode* sourceCode ); ~LineParser(); // Process the given line - void Process( std::string line ); + void Process( const std::string& line ); // Accessors diff --git a/src/sourcecode.cpp b/src/sourcecode.cpp index 0d21496..0647c6f 100644 --- a/src/sourcecode.cpp +++ b/src/sourcecode.cpp @@ -582,7 +582,7 @@ bool SourceCode::IsRealForLevel( int level ) const Search up the stack for a value for a symbol. N.B. This is dynamic scoping. */ /*************************************************************************************************/ -bool SourceCode::GetSymbolValue(std::string name, Value& value) +bool SourceCode::GetSymbolValue(const std::string& name, Value& value) { for ( int forLevel = GetForLevel(); forLevel >= 0; forLevel-- ) { diff --git a/src/sourcecode.h b/src/sourcecode.h index 433ac15..d453fea 100644 --- a/src/sourcecode.h +++ b/src/sourcecode.h @@ -121,7 +121,7 @@ class SourceCode inline int GetInitialForStackPtr() const { return m_initialForStackPtr; } inline Macro* GetCurrentMacro() { return m_currentMacro; } - bool GetSymbolValue(std::string name, Value& value); + bool GetSymbolValue(const std::string& name, Value& value); ScopedSymbolName GetScopedSymbolName( const std::string& symbolName, int level = -1 ) const; bool ShouldOutputAsm(); diff --git a/src/sourcefile.cpp b/src/sourcefile.cpp index fa9d012..09bc3df 100644 --- a/src/sourcefile.cpp +++ b/src/sourcefile.cpp @@ -48,7 +48,7 @@ using namespace std; The supplied file will be opened. If there is a problem, an AsmException will be thrown. */ /*************************************************************************************************/ -static string ReadFile( string filename ) +static string ReadFile( const string& filename ) { // we have to open in binary, due to a bug in MinGW which means that calling // tellg() on a text-mode file ruins the file pointer!