Skip to content

Commit

Permalink
Optimise destructors (pt 1)
Browse files Browse the repository at this point in the history
- Remove some non-base class empty destructors. These add no value
and it's better to let the compiler auto generate optimised versions
- use virtual ~Class = default instead of virtual ~Class {}
  • Loading branch information
nyalldawson committed Dec 30, 2016
1 parent 9021bb4 commit 850171c
Show file tree
Hide file tree
Showing 134 changed files with 50 additions and 313 deletions.
7 changes: 1 addition & 6 deletions src/analysis/interpolation/HalfEdge.h
Expand Up @@ -38,7 +38,7 @@ class ANALYSIS_EXPORT HalfEdge
//! Default constructor. Values for mDual, mNext, mPoint are set to -10 which means that they are undefined
HalfEdge();
HalfEdge( int dual, int next, int point, bool mbreak, bool forced );
~HalfEdge();

//! Returns the number of the dual HalfEdge
int getDual() const;
//! Returns the number of the next HalfEdge
Expand Down Expand Up @@ -71,11 +71,6 @@ inline HalfEdge::HalfEdge( int dual, int next, int point, bool mbreak, bool forc

}

inline HalfEdge::~HalfEdge()
{

}

inline int HalfEdge::getDual() const
{
return mDual;
Expand Down
6 changes: 0 additions & 6 deletions src/analysis/interpolation/Point3D.h
Expand Up @@ -35,7 +35,6 @@ class ANALYSIS_EXPORT Point3D
//! Constructor with the x-, y- and z-coordinate as arguments
Point3D( double x, double y, double z );
Point3D( const Point3D& p );
~Point3D();
Point3D& operator=( const Point3D& p );
bool operator==( const Point3D& p ) const;
bool operator!=( const Point3D& p ) const;
Expand Down Expand Up @@ -76,11 +75,6 @@ inline Point3D::Point3D( const Point3D& p ): mX( p.mX ), mY( p.mY ), mZ( p.mZ )

}

inline Point3D::~Point3D()
{

}

inline double Point3D::getX() const
{
return mX;
Expand Down
2 changes: 1 addition & 1 deletion src/analysis/interpolation/TriangleInterpolator.h
Expand Up @@ -25,7 +25,7 @@
class ANALYSIS_EXPORT TriangleInterpolator
{
public:
virtual ~TriangleInterpolator() {}
virtual ~TriangleInterpolator() = default;
//! Calculates the normal vector and assigns it to vec
virtual bool calcNormVec( double x, double y, Vector3D* result ) = 0;
//! Performs a linear interpolation in a triangle and assigns the x-,y- and z-coordinates to point
Expand Down
6 changes: 0 additions & 6 deletions src/analysis/interpolation/Vector3D.h
Expand Up @@ -43,7 +43,6 @@ class ANALYSIS_EXPORT Vector3D
//! Copy constructor
Vector3D( const Vector3D& v );

~Vector3D();
Vector3D& operator=( const Vector3D& v );
bool operator==( const Vector3D& v ) const;
bool operator!=( const Vector3D& v ) const;
Expand Down Expand Up @@ -83,11 +82,6 @@ inline Vector3D::Vector3D()

}

inline Vector3D::~Vector3D()
{

}

//-------------------------------------------setter and getters-------------------------------

inline double Vector3D::getX() const
Expand Down
5 changes: 0 additions & 5 deletions src/analysis/interpolation/qgsidwinterpolator.cpp
Expand Up @@ -29,11 +29,6 @@ QgsIDWInterpolator::QgsIDWInterpolator(): QgsInterpolator( QList<LayerData>() ),

}

QgsIDWInterpolator::~QgsIDWInterpolator()
{

}

int QgsIDWInterpolator::interpolatePoint( double x, double y, double& result )
{
if ( !mDataIsCached )
Expand Down
1 change: 0 additions & 1 deletion src/analysis/interpolation/qgsidwinterpolator.h
Expand Up @@ -27,7 +27,6 @@ class ANALYSIS_EXPORT QgsIDWInterpolator: public QgsInterpolator
{
public:
QgsIDWInterpolator( const QList<LayerData>& layerData );
~QgsIDWInterpolator();

/** Calculates interpolation value for map coordinates x, y
@param x x-coordinate (in map units)
Expand Down
2 changes: 1 addition & 1 deletion src/analysis/network/qgsnetworkstrategy.h
Expand Up @@ -39,7 +39,7 @@ class ANALYSIS_EXPORT QgsNetworkStrategy
*/
QgsNetworkStrategy() {}

virtual ~QgsNetworkStrategy() {}
virtual ~QgsNetworkStrategy() = default;

/**
* Returns list of the source layer attributes needed for cost calculation.
Expand Down
2 changes: 1 addition & 1 deletion src/analysis/raster/qgsalignraster.h
Expand Up @@ -147,7 +147,7 @@ class ANALYSIS_EXPORT QgsAlignRaster
//! @return false if the execution should be cancelled, true otherwise
virtual bool progress( double complete ) = 0;

virtual ~ProgressHandler() {}
virtual ~ProgressHandler() = default;
};

//! Assign a progress handler instance. Does not take ownership. nullptr can be passed.
Expand Down
5 changes: 0 additions & 5 deletions src/analysis/raster/qgsaspectfilter.cpp
Expand Up @@ -23,11 +23,6 @@ QgsAspectFilter::QgsAspectFilter( const QString& inputFile, const QString& outpu

}

QgsAspectFilter::~QgsAspectFilter()
{

}

float QgsAspectFilter::processNineCellWindow(
float* x11, float* x21, float* x31,
float* x12, float* x22, float* x32,
Expand Down
1 change: 0 additions & 1 deletion src/analysis/raster/qgsaspectfilter.h
Expand Up @@ -26,7 +26,6 @@ class ANALYSIS_EXPORT QgsAspectFilter: public QgsDerivativeFilter
{
public:
QgsAspectFilter( const QString& inputFile, const QString& outputFile, const QString& outputFormat );
~QgsAspectFilter();

/** Calculates output value from nine input values. The input values and the output value can be equal to the
nodata value if not present or outside of the border. Must be implemented by subclasses*/
Expand Down
4 changes: 0 additions & 4 deletions src/analysis/raster/qgshillshadefilter.cpp
Expand Up @@ -25,10 +25,6 @@ QgsHillshadeFilter::QgsHillshadeFilter( const QString& inputFile, const QString&
{
}

QgsHillshadeFilter::~QgsHillshadeFilter()
{
}

float QgsHillshadeFilter::processNineCellWindow( float* x11, float* x21, float* x31,
float* x12, float* x22, float* x32,
float* x13, float* x23, float* x33 )
Expand Down
1 change: 0 additions & 1 deletion src/analysis/raster/qgshillshadefilter.h
Expand Up @@ -28,7 +28,6 @@ class ANALYSIS_EXPORT QgsHillshadeFilter: public QgsDerivativeFilter
public:
QgsHillshadeFilter( const QString& inputFile, const QString& outputFile, const QString& outputFormat, double lightAzimuth = 300,
double lightAngle = 40 );
~QgsHillshadeFilter();

/** Calculates output value from nine input values. The input values and the output value can be equal to the
nodata value if not present or outside of the border. Must be implemented by subclasses*/
Expand Down
2 changes: 1 addition & 1 deletion src/analysis/vector/qgsgeometrysnapper.h
Expand Up @@ -122,7 +122,7 @@ class QgsSnapIndex
class SnapItem
{
public:
virtual ~SnapItem() {}
virtual ~SnapItem() = default;
SnapType type;
virtual QgsPointV2 getSnapPoint( const QgsPointV2& p ) const = 0;

Expand Down
2 changes: 0 additions & 2 deletions src/app/dwg/libdxfrw/drw_entities.h
Expand Up @@ -1237,8 +1237,6 @@ class DRW_Dimension : public DRW_Entity
{
}

virtual ~DRW_Dimension() {}

virtual void applyExtrusion() {}

protected:
Expand Down
2 changes: 1 addition & 1 deletion src/app/dwg/libdxfrw/intern/drw_dbg.cpp
Expand Up @@ -33,7 +33,7 @@ class print_none
virtual void printHL( int c, int s, int h ) {( void )c;( void )s;( void )h;}
virtual void printPT( double x, double y, double z ) {( void )x;( void )y;( void )z;}
print_none() {}
virtual ~print_none() {}
virtual ~print_none() = default;
};

class print_debug : public print_none
Expand Down
2 changes: 1 addition & 1 deletion src/app/dwg/libdxfrw/intern/drw_textcodec.h
Expand Up @@ -36,7 +36,7 @@ class DRW_Converter
table = t;
cpLenght = l;
}
virtual ~DRW_Converter() {}
virtual ~DRW_Converter() = default;
virtual std::string fromUtf8( std::string *s ) {return *s;}
virtual std::string toUtf8( std::string *s );
std::string encodeText( std::string stmp );
Expand Down
4 changes: 1 addition & 3 deletions src/app/dwg/libdxfrw/intern/dwgbuffer.h
Expand Up @@ -25,7 +25,7 @@ class dwgBasicStream
protected:
dwgBasicStream() {}
public:
virtual ~dwgBasicStream() {}
virtual ~dwgBasicStream() = default;
virtual bool read( duint8* s, duint64 n ) = 0;
virtual duint64 size() = 0;
virtual duint64 getPos() = 0;
Expand All @@ -44,7 +44,6 @@ class dwgFileStream: public dwgBasicStream
sz = stream->tellg();
stream->seekg( 0, std::ios_base::beg );
}
virtual ~dwgFileStream() {}
virtual bool read( duint8* s, duint64 n );
virtual duint64 size() {return sz;}
virtual duint64 getPos() {return stream->tellg();}
Expand All @@ -66,7 +65,6 @@ class dwgCharStream: public dwgBasicStream
pos = 0;
isOk = true;
}
virtual ~dwgCharStream() {}
virtual bool read( duint8* s, duint64 n );
virtual duint64 size() {return sz;}
virtual duint64 getPos() {return pos;}
Expand Down
4 changes: 2 additions & 2 deletions src/app/dwg/libdxfrw/intern/dwgreader.h
Expand Up @@ -69,7 +69,7 @@ class dwgPageInfo
, uSize( 0 )
{
}
~dwgPageInfo() {}

duint64 Id;
duint64 address; //in file stream, for rd18, rd21
duint64 size; //in file stream, for rd18, rd21
Expand Down Expand Up @@ -101,7 +101,7 @@ class dwgSectionInfo
, address( 0 )
{
}
~dwgSectionInfo() {}

dint32 Id; //section Id, 2000- rd15 rd18
std::string name; //section name rd18
duint32 compressed;//is compressed? 1=no, 2=yes rd18, rd21(encoding)
Expand Down
1 change: 0 additions & 1 deletion src/app/dwg/libdxfrw/intern/dwgreader15.h
Expand Up @@ -23,7 +23,6 @@ class dwgReader15 : public dwgReader
{
public:
dwgReader15( std::ifstream *stream, dwgR *p ): dwgReader( stream, p ) { }
virtual ~dwgReader15() {}
bool readMetaData();
bool readFileHeader();
bool readDwgHeader( DRW_Header& hdr );
Expand Down
1 change: 0 additions & 1 deletion src/app/dwg/libdxfrw/intern/dwgreader24.h
Expand Up @@ -23,7 +23,6 @@ class dwgReader24 : public dwgReader18
{
public:
dwgReader24( std::ifstream *stream, dwgR *p ): dwgReader18( stream, p ) { }
virtual ~dwgReader24() {}
bool readFileHeader();
bool readDwgHeader( DRW_Header& hdr );
bool readDwgClasses();
Expand Down
1 change: 0 additions & 1 deletion src/app/dwg/libdxfrw/intern/dwgreader27.h
Expand Up @@ -23,7 +23,6 @@ class dwgReader27 : public dwgReader18
{
public:
dwgReader27( std::ifstream *stream, dwgR *p ): dwgReader18( stream, p ) { }
virtual ~dwgReader27() {}
bool readFileHeader();
bool readDwgHeader( DRW_Header& hdr );
bool readDwgClasses();
Expand Down
5 changes: 1 addition & 4 deletions src/app/dwg/libdxfrw/intern/dwgutil.h
Expand Up @@ -24,7 +24,7 @@ class dwgRSCodec
{
public:
dwgRSCodec() {}
~dwgRSCodec() {}

static void decode239I( duint8 *in, duint8 *out, duint32 blk );
static void decode251I( duint8 *in, duint8 *out, duint32 blk );
};
Expand All @@ -41,8 +41,6 @@ class dwgCompressor
, rpos( 0 )
{}

~dwgCompressor() {}

void decompress18( duint8 *cbuf, duint8 *dbuf, duint32 csize, duint32 dsize );
static void decrypt18Hdr( duint8 *buf, duint32 size, duint32 offset );
// static void decrypt18Data(duint8 *buf, duint32 size, duint32 offset);
Expand Down Expand Up @@ -96,7 +94,6 @@ class secEnum
};

secEnum() {}
~secEnum() {}

static DWGSection getEnum( std::string nameSec );
};
Expand Down
4 changes: 1 addition & 3 deletions src/app/dwg/libdxfrw/intern/dxfreader.h
Expand Up @@ -38,7 +38,7 @@ class dxfReader
filestr = stream;
type = INVALID;
}
virtual ~dxfReader() {}
virtual ~dxfReader() = default;
bool readRec( int *code );

std::string getString() {return strData;}
Expand Down Expand Up @@ -81,7 +81,6 @@ class dxfReaderBinary : public dxfReader
explicit dxfReaderBinary( std::ifstream *stream )
: dxfReader( stream, false )
{}
virtual ~dxfReaderBinary() {}
virtual bool readCode( int *code );
virtual bool readString( std::string *text );
virtual bool readString();
Expand All @@ -98,7 +97,6 @@ class dxfReaderAscii : public dxfReader
explicit dxfReaderAscii( std::ifstream *stream )
: dxfReader( stream, true )
{}
virtual ~dxfReaderAscii() {}
virtual bool readCode( int *code );
virtual bool readString( std::string *text );
virtual bool readString();
Expand Down
4 changes: 1 addition & 3 deletions src/app/dwg/libdxfrw/intern/dxfwriter.h
Expand Up @@ -22,7 +22,7 @@ class dxfWriter
: filestr( stream )
// , count( 0 )
{}
virtual ~dxfWriter() {}
virtual ~dxfWriter() = default;
virtual bool writeString( int code, std::string text ) = 0;
bool writeUtf8String( int code, std::string text );
bool writeUtf8Caps( int code, std::string text );
Expand All @@ -47,7 +47,6 @@ class dxfWriterBinary : public dxfWriter
explicit dxfWriterBinary( std::ofstream *stream )
: dxfWriter( stream )
{}
virtual ~dxfWriterBinary() {}
virtual bool writeString( int code, std::string text );
virtual bool writeInt16( int code, int data );
virtual bool writeInt32( int code, int data );
Expand All @@ -60,7 +59,6 @@ class dxfWriterAscii : public dxfWriter
{
public:
explicit dxfWriterAscii( std::ofstream *stream );
virtual ~dxfWriterAscii() {}
virtual bool writeString( int code, std::string text );
virtual bool writeInt16( int code, int data );
virtual bool writeInt32( int code, int data );
Expand Down
2 changes: 0 additions & 2 deletions src/app/qgsattributeactiondialog.h
Expand Up @@ -49,8 +49,6 @@ class APP_EXPORT QgsAttributeActionDialog: public QWidget, private Ui::QgsAttrib
QgsAttributeActionDialog( const QgsActionManager& actions,
QWidget* parent = nullptr );

~QgsAttributeActionDialog() {}

void init( const QgsActionManager& action , const QgsAttributeTableConfig& attributeTableConfig );

QList<QgsAction> actions() const;
Expand Down
3 changes: 0 additions & 3 deletions src/app/qgsdecorationcopyright.cpp
Expand Up @@ -54,9 +54,6 @@ QgsDecorationCopyright::QgsDecorationCopyright( QObject* parent )
projectRead();
}

QgsDecorationCopyright::~QgsDecorationCopyright()
{}

void QgsDecorationCopyright::projectRead()
{
QgsDecorationItem::projectRead();
Expand Down
2 changes: 0 additions & 2 deletions src/app/qgsdecorationcopyright.h
Expand Up @@ -37,8 +37,6 @@ class APP_EXPORT QgsDecorationCopyright : public QgsDecorationItem
//! Constructor
QgsDecorationCopyright( QObject* parent = nullptr );

virtual ~QgsDecorationCopyright();

public slots:
//! set values on the gui when a project is read or the gui first loaded
void projectRead() override;
Expand Down
2 changes: 0 additions & 2 deletions src/core/auth/qgsauthconfig.h
Expand Up @@ -299,8 +299,6 @@ class CORE_EXPORT QgsAuthConfigSslServer
//! Construct a default SSL server configuration
QgsAuthConfigSslServer();

~QgsAuthConfigSslServer() {}

//! Server certificate object
const QSslCertificate sslCertificate() const { return mSslCert; }
//! Set server certificate object
Expand Down
2 changes: 0 additions & 2 deletions src/core/auth/qgsauthmethod.h
Expand Up @@ -53,8 +53,6 @@ class CORE_EXPORT QgsAuthMethod : public QObject
};
Q_DECLARE_FLAGS( Expansions, Expansion )

virtual ~QgsAuthMethod() {}

//! A non-translated short name representing the auth method
virtual QString key() const = 0;

Expand Down
2 changes: 1 addition & 1 deletion src/core/effects/qgspainteffectregistry.h
Expand Up @@ -43,7 +43,7 @@ class CORE_EXPORT QgsPaintEffectAbstractMetadata
*/
QgsPaintEffectAbstractMetadata( const QString& name, const QString& visibleName );

virtual ~QgsPaintEffectAbstractMetadata() {}
virtual ~QgsPaintEffectAbstractMetadata() = default;

/** Returns the unique string representing the paint effect class
* @returns unique string
Expand Down
4 changes: 0 additions & 4 deletions src/core/geometry/qgsabstractgeometry.cpp
Expand Up @@ -27,10 +27,6 @@ QgsAbstractGeometry::QgsAbstractGeometry(): mWkbType( QgsWkbTypes::Unknown )
{
}

QgsAbstractGeometry::~QgsAbstractGeometry()
{
}

QgsAbstractGeometry::QgsAbstractGeometry( const QgsAbstractGeometry& geom )
{
mWkbType = geom.mWkbType;
Expand Down

0 comments on commit 850171c

Please sign in to comment.