Commit 3542db88 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Fix cppcheck performance: Function parameter should be passed by const reference.

parent 2052b4cb
......@@ -738,7 +738,7 @@ static void
after_setLevel(struct Control *globs)
{
int k, l, found;
int removeLevel[MaxLevel];
bool removeLevel[MaxLevel];
double level;
bool checkLevel = true;
// default pressure level
......
......@@ -227,7 +227,7 @@ remapGetNormOpt(const std::string &normOptStr)
RemapMethod getMapType(int ncfileid, SubmapType *submapType, int *numNeighbors, int &remapOrder);
static void
readRemapGridScrip(const int ncfileid, const std::string prefix, bool lgridarea, RemapGridW &grid)
readRemapGridScrip(const int ncfileid, const std::string &prefix, bool lgridarea, RemapGridW &grid)
{
// Read all variables of the grid
cdfReadVarSize(ncfileid, (prefix + "_dims").c_str(), 2, grid.dims);
......@@ -457,7 +457,7 @@ struct CDFgrid
};
static CDFgrid
defineRemapGridScrip(const int ncfileid, const std::string prefix, nc_type sizetype, bool lgridarea, const RemapGridW &grid)
defineRemapGridScrip(const int ncfileid, const std::string &prefix, nc_type sizetype, bool lgridarea, const RemapGridW &grid)
{
CDFgrid cdfGrid;
......
......@@ -27,7 +27,7 @@
#include "cdi_lockedIO.h"
static void
varrms(const Varray<double> w, const FieldVector &field1, const FieldVector &field2, Field &field3)
varrms(const Varray<double> &w, const FieldVector &field1, const FieldVector &field2, Field &field3)
{
const auto grid1 = field1[0].grid;
const auto grid2 = field2[0].grid;
......
......@@ -132,12 +132,9 @@ scan(std::vector<std::string> p_argv)
}
std::vector<std::string>
expandApply(std::vector<std::string> p_argv)
expandApply(std::vector<std::string> &p_argv)
{
auto result = scan(p_argv);
if (errState == -1)
{
exit(EXIT_FAILURE);
}
if (errState == -1) exit(EXIT_FAILURE);
return result;
}
......@@ -24,6 +24,6 @@
* operators with arguments: written as -apply,OPERNAME,arguments
*/
std::vector<std::string> expandApply(std::vector<std::string> p_argv);
std::vector<std::string> expandApply(std::vector<std::string> &p_argv);
#endif
......@@ -32,7 +32,7 @@ extern int processNum;
bool FileStream::TimerEnabled = false;
FileStream::FileStream(std::string p_fileName) : m_filename(p_fileName)
FileStream::FileStream(const std::string &p_fileName) : m_filename(p_fileName)
{
m_name = p_fileName;
m_fileID = CDI_UNDEFID;
......
......@@ -25,7 +25,7 @@ class FileStream : public CdoStream
{
public:
// Constructors
FileStream(std::string p_fileStream);
FileStream(const std::string &p_fileStream);
// ---
// CdoStream Interface functions
......
......@@ -258,14 +258,9 @@ cdoOpenWrite(int p_outStreamIDX, int filetype)
return outStream;
}
int
cdoStreamOpenWrite(int p_outStreamIDX, int filetype)
{
return cdoOpenWrite(p_outStreamIDX, filetype)->getID();
}
CdoStreamID
cdoOpenWrite(std::string p_filename, int filetype)
cdoOpenWrite(const std::string &p_filename, int filetype)
{
if (filetype == CDI_UNDEFID) filetype = cdoFiletype();
......@@ -277,12 +272,6 @@ cdoOpenWrite(std::string p_filename, int filetype)
return localProcess->outputStreams.back();
}
int
cdoStreamOpenWrite(std::string p_filename, int filetype)
{
return cdoOpenWrite(p_filename, filetype)->getID();
}
CdoStreamID
cdoOpenAppend(int p_outFileIndex)
{
......
......@@ -81,7 +81,7 @@ void cdoDefCompType(CdoStreamID p_streamID, int p_cdi_compression_type);
CdoStreamID cdoOpenAppend(int outStreamIDX);
CdoStreamID cdoOpenRead(int inStreamIDX);
CdoStreamID cdoOpenWrite(int outStreamIDX, int filetype = CDI_UNDEFID);
CdoStreamID cdoOpenWrite(std::string p_filename, int filetype = CDI_UNDEFID);
CdoStreamID cdoOpenWrite(const std::string &p_filename, int filetype = CDI_UNDEFID);
int cdoOperatorAdd(const char *name, int f1, int f2, const char *enter);
int cdoOperatorF1(int operID);
int cdoOperatorF2(int operID);
......
......@@ -18,12 +18,6 @@
#include "cdo_default_values.h"
bool
fileExists(const std::string filename)
{
return fileExists(filename.c_str());
}
bool
fileExists(const char *restrict filename)
{
......@@ -38,6 +32,12 @@ fileExists(const char *restrict filename)
return status;
}
bool
fileExists(const std::string &filename)
{
return fileExists(filename.c_str());
}
bool
userFileOverwrite(const char *restrict filename)
{
......@@ -68,7 +68,7 @@ userFileOverwrite(const char *restrict filename)
}
off_t
fileSize(const char *restrict filename)
fileSize(const char *filename)
{
off_t filesize = 0;
......
......@@ -20,7 +20,7 @@
#include <sys/types.h>
#include <string>
bool fileExists(const std::string filename);
bool fileExists(const std::string &filename);
bool fileExists(const char *filename);
bool userFileOverwrite(const char *filename);
off_t fileSize(const char *filename);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment