Hi, There are a few accessors in D_PAD that could do with const qualifiers.
Also a few functions return non-POD objects by const value. This doesn't actually acheive anything, except forcing the compiler to forgo move operations and use copies instead, which is just less efficient. It doesn't actually convey any meaning about the data itself (the calling code is the one to decide if it wants to call its newly copied/moved object "const" or not). If the functions returned const ref or const pointer, then it would have meaning. I didn't change them all, as some are overrides that are part of a larger inheriance hierarchy. Cheers, John
From 4f726e83fb44f5057a28b05777bfef5613b3fbf9 Mon Sep 17 00:00:00 2001 From: John Beard <[email protected]> Date: Sun, 22 Jan 2017 04:19:46 +0800 Subject: [PATCH 1/2] Tidy consts for class D_PAD Some accessors should be const: * IsFlipped * GetRoundRectRadiusRatio Returning a objects by value as const in these cases is not helpful, as all it does is prevent the caller moving from the return value, it just forces a copy. Some of thse functions come from base class overrides, those haven't been changed. * ShapePos * GetPadName * GetPackedPadName --- pcbnew/class_pad.cpp | 6 +++--- pcbnew/class_pad.h | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pcbnew/class_pad.cpp b/pcbnew/class_pad.cpp index cab53dbda..d4822f71f 100644 --- a/pcbnew/class_pad.cpp +++ b/pcbnew/class_pad.cpp @@ -120,7 +120,7 @@ LSET D_PAD::UnplatedHoleMask() return saved; } -bool D_PAD::IsFlipped() +bool D_PAD::IsFlipped() const { if( GetParent() && GetParent()->GetLayer() == B_Cu ) return true; @@ -363,7 +363,7 @@ void D_PAD::AppendConfigs( PARAM_CFG_ARRAY* aResult ) // Returns the position of the pad. -const wxPoint D_PAD::ShapePos() const +wxPoint D_PAD::ShapePos() const { if( m_Offset.x == 0 && m_Offset.y == 0 ) return m_Pos; @@ -378,7 +378,7 @@ const wxPoint D_PAD::ShapePos() const } -const wxString D_PAD::GetPadName() const +wxString D_PAD::GetPadName() const { wxString name; diff --git a/pcbnew/class_pad.h b/pcbnew/class_pad.h index c4689630f..6072fec05 100644 --- a/pcbnew/class_pad.h +++ b/pcbnew/class_pad.h @@ -111,7 +111,7 @@ public: * @return true if the pad has a footprint parent flipped * (on the back/bottom layer) */ - bool IsFlipped(); + bool IsFlipped() const; /** * Set the pad name (sometimes called pad number, although @@ -124,7 +124,7 @@ public: * @return the pad name * the pad name is limited to 4 ASCII chars */ - const wxString GetPadName() const; + wxString GetPadName() const; /** * @return the pad name in a wxUint32 which is possible @@ -132,7 +132,7 @@ public: * The packed pad name should be used only to compare 2 * pad names, not to try to print this name */ - const wxUint32 GetPackedPadName() const { return m_NumPadName; } + wxUint32 GetPackedPadName() const { return m_NumPadName; } /** * Function IncrementPadName @@ -430,7 +430,7 @@ public: return m_boundingRadius; } - const wxPoint ShapePos() const; + wxPoint ShapePos() const; /** * has meaning only for rounded rect pads @@ -439,7 +439,7 @@ public: * Cannot be > 0.5 * the normalized IPC-7351C value is 0.25 */ - double GetRoundRectRadiusRatio() + double GetRoundRectRadiusRatio() const { return m_padRoundRectRadiusScale; } -- 2.11.0
_______________________________________________ Mailing list: https://launchpad.net/~kicad-developers Post to : [email protected] Unsubscribe : https://launchpad.net/~kicad-developers More help : https://help.launchpad.net/ListHelp

