Skip to content

Commit

Permalink
cppcheck performance fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tobbi committed Jan 24, 2015
1 parent 5ac8631 commit e910a7b
Show file tree
Hide file tree
Showing 36 changed files with 97 additions and 106 deletions.
2 changes: 1 addition & 1 deletion xbmc/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3204,7 +3204,7 @@ bool CApplication::ProcessEventServer(float frameTime)
}
}

if (m_lastAxisMap.size() > 0)
if (!m_lastAxisMap.empty())
{
// Process all the stored axis.
for (map<std::string, map<int, float> >::iterator iter = m_lastAxisMap.begin(); iter != m_lastAxisMap.end(); ++iter)
Expand Down
8 changes: 4 additions & 4 deletions xbmc/ApplicationMessenger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ void CApplicationMessenger::Cleanup()
{
CSingleLock lock (m_critSection);

while (m_vecMessages.size() > 0)
while (!m_vecMessages.empty())
{
ThreadMessage* pMsg = m_vecMessages.front();

Expand All @@ -129,7 +129,7 @@ void CApplicationMessenger::Cleanup()
m_vecMessages.pop();
}

while (m_vecWindowMessages.size() > 0)
while (!m_vecWindowMessages.empty())
{
ThreadMessage* pMsg = m_vecWindowMessages.front();

Expand Down Expand Up @@ -203,7 +203,7 @@ void CApplicationMessenger::ProcessMessages()
{
// process threadmessages
CSingleLock lock (m_critSection);
while (m_vecMessages.size() > 0)
while (!m_vecMessages.empty())
{
ThreadMessage* pMsg = m_vecMessages.front();
//first remove the message from the queue, else the message could be processed more then once
Expand Down Expand Up @@ -871,7 +871,7 @@ void CApplicationMessenger::ProcessWindowMessages()
{
CSingleLock lock (m_critSection);
//message type is window, process window messages
while (m_vecWindowMessages.size() > 0)
while (!m_vecWindowMessages.empty())
{
ThreadMessage* pMsg = m_vecWindowMessages.front();
//first remove the message from the queue, else the message could be processed more then once
Expand Down
5 changes: 1 addition & 4 deletions xbmc/CueDocument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,6 @@ using namespace XFILE;

CCueDocument::CCueDocument(void)
{
m_strArtist = "";
m_strAlbum = "";
m_strGenre = "";
m_iYear = 0;
m_replayGainAlbumPeak = 0.0f;
m_replayGainAlbumGain = 0.0f;
Expand Down Expand Up @@ -249,7 +246,7 @@ void CCueDocument::GetMediaFiles(vector<std::string>& mediaFiles)
for (int i = 0; i < m_iTotalTracks; i++)
uniqueFiles.insert(m_Track[i].strFile);

for (set<std::string>::iterator it = uniqueFiles.begin(); it != uniqueFiles.end(); it++)
for (set<std::string>::iterator it = uniqueFiles.begin(); it != uniqueFiles.end(); ++it)
mediaFiles.push_back(*it);
}

Expand Down
4 changes: 2 additions & 2 deletions xbmc/DynamicDll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ DllDynamic::DllDynamic()
m_DelayUnload=true;
}

DllDynamic::DllDynamic(const std::string& strDllName)
DllDynamic::DllDynamic(const std::string& strDllName):
m_strDllName(strDllName)
{
m_strDllName=strDllName;
m_dll=NULL;
m_DelayUnload=true;
}
Expand Down
2 changes: 1 addition & 1 deletion xbmc/GUIInfoManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5662,7 +5662,7 @@ std::string CGUIInfoManager::GetSkinVariableString(int info,

bool CGUIInfoManager::ConditionsChangedValues(const std::map<INFO::InfoPtr, bool>& map)
{
for (std::map<INFO::InfoPtr, bool>::const_iterator it = map.begin() ; it != map.end() ; it++)
for (std::map<INFO::InfoPtr, bool>::const_iterator it = map.begin() ; it != map.end() ; ++it)
{
if (it->first->Get() != it->second)
return true;
Expand Down
8 changes: 4 additions & 4 deletions xbmc/GUILargeTextureManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
using namespace std;


CImageLoader::CImageLoader(const std::string &path, const bool useCache)
CImageLoader::CImageLoader(const std::string &path, const bool useCache):
m_path(path)
{
m_path = path;
m_texture = NULL;
m_use_cache = useCache;
}
Expand Down Expand Up @@ -78,9 +78,9 @@ bool CImageLoader::DoWork()
return true;
}

CGUILargeTextureManager::CLargeTexture::CLargeTexture(const std::string &path)
CGUILargeTextureManager::CLargeTexture::CLargeTexture(const std::string &path):
m_path(path)
{
m_path = path;
m_refCount = 1;
m_timeToDelete = 0;
}
Expand Down
33 changes: 15 additions & 18 deletions xbmc/LangInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,28 +44,25 @@ using namespace PVR;

#define SPEED_UNIT_STRINGS 20200

CLangInfo::CRegion::CRegion(const CRegion& region)
{
m_strName=region.m_strName;
m_forceUnicodeFont=region.m_forceUnicodeFont;
m_strGuiCharSet=region.m_strGuiCharSet;
m_strSubtitleCharSet=region.m_strSubtitleCharSet;
m_strDVDMenuLanguage=region.m_strDVDMenuLanguage;
m_strDVDAudioLanguage=region.m_strDVDAudioLanguage;
m_strDVDSubtitleLanguage=region.m_strDVDSubtitleLanguage;
m_strLangLocaleName = region.m_strLangLocaleName;
m_strLangLocaleCodeTwoChar = region.m_strLangLocaleCodeTwoChar;
m_strRegionLocaleName = region.m_strRegionLocaleName;

m_strDateFormatShort=region.m_strDateFormatShort;
m_strDateFormatLong=region.m_strDateFormatLong;
m_strTimeFormat=region.m_strTimeFormat;
CLangInfo::CRegion::CRegion(const CRegion& region):
m_strGuiCharSet(region.m_strGuiCharSet),
m_strSubtitleCharSet(region.m_strSubtitleCharSet),
m_strDVDMenuLanguage(region.m_strDVDMenuLanguage),
m_strDVDAudioLanguage(region.m_strDVDAudioLanguage),
m_strDVDSubtitleLanguage(region.m_strDVDSubtitleLanguage),
m_strLangLocaleName(region.m_strLangLocaleName),
m_strLangLocaleCodeTwoChar(region.m_strLangLocaleCodeTwoChar),
m_strRegionLocaleName(region.m_strRegionLocaleName),
m_strName(region.m_strName),
m_strDateFormatLong(region.m_strDateFormatLong),
m_strDateFormatShort(region.m_strDateFormatShort),
m_strTimeFormat(region.m_strTimeFormat),
m_strTimeZone(region.m_strTimeZone)
{
m_strMeridiemSymbols[MERIDIEM_SYMBOL_PM]=region.m_strMeridiemSymbols[MERIDIEM_SYMBOL_PM];
m_strMeridiemSymbols[MERIDIEM_SYMBOL_AM]=region.m_strMeridiemSymbols[MERIDIEM_SYMBOL_AM];
m_strTimeFormat=region.m_strTimeFormat;
m_tempUnit=region.m_tempUnit;
m_speedUnit=region.m_speedUnit;
m_strTimeZone = region.m_strTimeZone;
}

CLangInfo::CRegion::CRegion()
Expand Down
2 changes: 1 addition & 1 deletion xbmc/PartyModeManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ bool CPartyModeManager::AddInitialSongs(vector<pair<int,int> > &songIDs)
std::string sqlWhereMusic = "songview.idSong IN (";
std::string sqlWhereVideo = "idMVideo IN (";

for (vector< pair<int,int> >::iterator it = chosenSongIDs.begin(); it != chosenSongIDs.end(); it++)
for (vector< pair<int,int> >::iterator it = chosenSongIDs.begin(); it != chosenSongIDs.end(); ++it)
{
std::string song = StringUtils::Format("%i,", it->second);
if (it->first == 1)
Expand Down
12 changes: 6 additions & 6 deletions xbmc/TextureCacheJob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@
#include "cores/omxplayer/OMXImage.h"
#endif

CTextureCacheJob::CTextureCacheJob(const std::string &url, const std::string &oldHash)
CTextureCacheJob::CTextureCacheJob(const std::string &url, const std::string &oldHash):
m_url(url),
m_oldHash(oldHash),
m_cachePath(CTextureCache::GetCacheFile(m_url))
{
m_url = url;
m_oldHash = oldHash;
m_cachePath = CTextureCache::GetCacheFile(m_url);
}

CTextureCacheJob::~CTextureCacheJob()
Expand Down Expand Up @@ -208,9 +208,9 @@ std::string CTextureCacheJob::GetImageHash(const std::string &url)
return "";
}

CTextureDDSJob::CTextureDDSJob(const std::string &original)
CTextureDDSJob::CTextureDDSJob(const std::string &original):
m_original(original)
{
m_original = original;
}

bool CTextureDDSJob::operator==(const CJob* job) const
Expand Down
6 changes: 3 additions & 3 deletions xbmc/dialogs/GUIDialogContextMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ float CGUIDialogContextMenu::GetWidth() const
return CGUIDialog::GetWidth();
}

bool CGUIDialogContextMenu::SourcesMenu(const std::string &strType, const CFileItemPtr item, float posX, float posY)
bool CGUIDialogContextMenu::SourcesMenu(const std::string &strType, const CFileItemPtr& item, float posX, float posY)
{
// TODO: This should be callable even if we don't have any valid items
if (!item)
Expand All @@ -224,7 +224,7 @@ bool CGUIDialogContextMenu::SourcesMenu(const std::string &strType, const CFileI
return false;
}

void CGUIDialogContextMenu::GetContextButtons(const std::string &type, const CFileItemPtr item, CContextButtons &buttons)
void CGUIDialogContextMenu::GetContextButtons(const std::string &type, const CFileItemPtr& item, CContextButtons &buttons)
{
// Add buttons to the ContextMenu that should be visible for both sources and autosourced items
if (item && item->IsRemovable())
Expand Down Expand Up @@ -301,7 +301,7 @@ void CGUIDialogContextMenu::GetContextButtons(const std::string &type, const CFi
buttons.Add(CONTEXT_BUTTON_REACTIVATE_LOCK, 12353);
}

bool CGUIDialogContextMenu::OnContextButton(const std::string &type, const CFileItemPtr item, CONTEXT_BUTTON button)
bool CGUIDialogContextMenu::OnContextButton(const std::string &type, const CFileItemPtr& item, CONTEXT_BUTTON button)
{
// Add Source doesn't require a valid share
if (button == CONTEXT_BUTTON_ADD_SOURCE)
Expand Down
6 changes: 3 additions & 3 deletions xbmc/dialogs/GUIDialogContextMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,11 @@ class CGUIDialogContextMenu :
virtual bool OnAction(const CAction& action);
virtual void SetPosition(float posX, float posY);

static bool SourcesMenu(const std::string &strType, const CFileItemPtr item, float posX, float posY);
static bool SourcesMenu(const std::string &strType, const CFileItemPtr& item, float posX, float posY);
static void SwitchMedia(const std::string& strType, const std::string& strPath);

static void GetContextButtons(const std::string &type, const CFileItemPtr item, CContextButtons &buttons);
static bool OnContextButton(const std::string &type, const CFileItemPtr item, CONTEXT_BUTTON button);
static void GetContextButtons(const std::string &type, const CFileItemPtr& item, CContextButtons &buttons);
static bool OnContextButton(const std::string &type, const CFileItemPtr& item, CONTEXT_BUTTON button);

/*! \brief Show the context menu with the given choices
\param choices the choices available for the user.
Expand Down
8 changes: 4 additions & 4 deletions xbmc/filesystem/test/TestFileFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ class TestFileFactory : public testing::Test
CXBMCTestUtils::Instance().getGUISettingsFiles();

std::vector<std::string>::iterator it;
for (it = guisettings.begin(); it < guisettings.end(); it++)
for (it = guisettings.begin(); it < guisettings.end(); ++it)
CSettings::Get().Load(*it);

for (it = advancedsettings.begin(); it < advancedsettings.end(); it++)
for (it = advancedsettings.begin(); it < advancedsettings.end(); ++it)
g_advancedSettings.ParseSettingsFile(*it);

CSettings::Get().SetLoaded();
Expand Down Expand Up @@ -74,7 +74,7 @@ TEST_F(TestFileFactory, Read)
CXBMCTestUtils::Instance().getTestFileFactoryReadUrls();

std::vector<std::string>::iterator it;
for (it = urls.begin(); it < urls.end(); it++)
for (it = urls.begin(); it < urls.end(); ++it)
{
std::cout << "Testing URL: " << *it << std::endl;
ASSERT_TRUE(file.Open(*it));
Expand Down Expand Up @@ -128,7 +128,7 @@ TEST_F(TestFileFactory, Write)
CXBMCTestUtils::Instance().getTestFileFactoryWriteUrls();

std::vector<std::string>::iterator it;
for (it = urls.begin(); it < urls.end(); it++)
for (it = urls.begin(); it < urls.end(); ++it)
{
std::cout << "Testing URL: " << *it << std::endl;
std::cout << "Writing...";
Expand Down
4 changes: 2 additions & 2 deletions xbmc/guilib/GUIFont.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ float CScrollInfo::GetPixelsPerFrame()
}

CGUIFont::CGUIFont(const std::string& strFontName, uint32_t style, color_t textColor,
color_t shadowColor, float lineSpacing, float origHeight, CGUIFontTTFBase *font)
color_t shadowColor, float lineSpacing, float origHeight, CGUIFontTTFBase *font):
m_strFontName(strFontName)
{
m_strFontName = strFontName;
m_style = style & FONT_STYLE_MASK;
m_textColor = textColor;
m_shadowColor = shadowColor;
Expand Down
4 changes: 2 additions & 2 deletions xbmc/guilib/GUILabel.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@
class CLabelInfo
{
public:
CLabelInfo()
CLabelInfo():
scrollSuffix(" | ")
{
font = NULL;
align = XBFONT_LEFT;
offsetX = offsetY = 0;
width = 0;
angle = 0;
scrollSpeed = CScrollInfo::defaultSpeed;
scrollSuffix = " | ";
};
bool UpdateColors()
{
Expand Down
2 changes: 1 addition & 1 deletion xbmc/guilib/GUIMultiSelectText.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ using namespace std;

CGUIMultiSelectTextControl::CSelectableString::CSelectableString(CGUIFont *font, const std::string &text, bool selectable, const std::string &clickAction)
: m_text(font, false)
, m_clickAction(clickAction)
{
m_selectable = selectable;
m_clickAction = clickAction;
StringUtils::TrimLeft(m_clickAction, " =");
StringUtils::TrimRight(m_clickAction);
m_text.Update(text);
Expand Down
5 changes: 2 additions & 3 deletions xbmc/guilib/GUIRSSControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,13 @@ using namespace std;

CGUIRSSControl::CGUIRSSControl(int parentID, int controlID, float posX, float posY, float width, float height, const CLabelInfo& labelInfo, const CGUIInfoColor &channelColor, const CGUIInfoColor &headlineColor, std::string& strRSSTags)
: CGUIControl(parentID, controlID, posX, posY, width, height),
m_strRSSTags(strRSSTags),
m_label(labelInfo),
m_channelColor(channelColor),
m_headlineColor(headlineColor),
m_scrollInfo(0,0,labelInfo.scrollSpeed,""),
m_dirty(true)
{
m_strRSSTags = strRSSTags;

m_pReader = NULL;
m_rtl = false;
m_stopped = false;
Expand All @@ -49,6 +48,7 @@ CGUIRSSControl::CGUIRSSControl(int parentID, int controlID, float posX, float po
CGUIRSSControl::CGUIRSSControl(const CGUIRSSControl &from)
: CGUIControl(from),
m_feed(),
m_strRSSTags(from.m_strRSSTags),
m_label(from.m_label),
m_channelColor(from.m_channelColor),
m_headlineColor(from.m_headlineColor),
Expand All @@ -57,7 +57,6 @@ CGUIRSSControl::CGUIRSSControl(const CGUIRSSControl &from)
m_scrollInfo(from.m_scrollInfo),
m_dirty(true)
{
m_strRSSTags = from.m_strRSSTags;
m_pReader = NULL;
m_rtl = from.m_rtl;
m_stopped = from.m_stopped;
Expand Down
4 changes: 2 additions & 2 deletions xbmc/guilib/GUITexture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ CTextureInfo::CTextureInfo()
useLarge = false;
}

CTextureInfo::CTextureInfo(const std::string &file)
CTextureInfo::CTextureInfo(const std::string &file):
filename(file)
{
orientation = 0;
useLarge = false;
filename = file;
}

CTextureInfo& CTextureInfo::operator=(const CTextureInfo &right)
Expand Down
1 change: 0 additions & 1 deletion xbmc/guilib/JpegIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ CJpegIO::CJpegIO()
m_orientation = 0;
m_inputBuffSize = 0;
m_inputBuff = NULL;
m_texturePath = "";
memset(&m_cinfo, 0, sizeof(m_cinfo));
m_thumbnailbuffer = NULL;
}
Expand Down
Loading

0 comments on commit e910a7b

Please sign in to comment.