do not pass by reference arguments of small types
authorFrantišek Kučera <franta-hg@frantovo.cz>
Thu, 28 Dec 2017 23:11:43 +0100
changeset 37b63d62c675fe
parent 36 2b3a26d3b1ad
child 38 b5e31973fe20
do not pass by reference arguments of small types
c++/rgb-assembler/Memory.h
     1.1 --- a/c++/rgb-assembler/Memory.h	Wed Dec 27 11:34:09 2017 +0100
     1.2 +++ b/c++/rgb-assembler/Memory.h	Thu Dec 28 23:11:43 2017 +0100
     1.3 @@ -23,7 +23,7 @@
     1.4  class Memory {
     1.5  private:
     1.6  
     1.7 -	template<typename T> T logMemoryError(const address_t &index) {
     1.8 +	template<typename T> T logMemoryError(const address_t index) {
     1.9  		wprintf(L"memory error: index = %d, sizeof(T) = %d, MEMORY_SIZE = %d\n", index, sizeof (T), memorySize);
    1.10  		// TODO: return error value or throw exception
    1.11  		return T();
    1.12 @@ -64,7 +64,7 @@
    1.13  	 * Reads data on given position in memory (without affecting the current position).
    1.14  	 * @return value found at given position
    1.15  	 */
    1.16 -	template<typename T> T read(const address_t &address) {
    1.17 +	template<typename T> T read(const address_t address) {
    1.18  		// TODO: map higher memory to static hardcoded areas or peripherals
    1.19  		if (address + sizeof (T) <= memorySize) {
    1.20  			return *(reinterpret_cast<T*> (memory + address));
    1.21 @@ -91,7 +91,7 @@
    1.22  	 * Writes data to given position in memory (without affecting the current position).
    1.23  	 * @param value value to be written at given position
    1.24  	 */
    1.25 -	template<typename T> void write(const address_t &address, const T value) {
    1.26 +	template<typename T> void write(const address_t address, const T value) {
    1.27  		if (address + sizeof (T) <= memorySize) {
    1.28  			T * m = reinterpret_cast<T*> (memory + address);
    1.29  			*m = value;
    1.30 @@ -104,7 +104,7 @@
    1.31  	 * Set current addres to given position.
    1.32  	 * @param index
    1.33  	 */
    1.34 -	void setAddress(address_t &index) {
    1.35 +	void setAddress(address_t index) {
    1.36  		this->index = index;
    1.37  	}
    1.38