mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-20 15:08:19 +00:00
Merge #3038
3038: Use std::sort instead of bubble_sort r=def- a=Jupeyy Noticed, that its really slow, when you have alot of auto demos Co-authored-by: Jupeyy <jupjopjap@gmail.com>
This commit is contained in:
commit
2d0c65bf53
|
@ -4,6 +4,7 @@
|
||||||
#define BASE_TL_ALGORITHM_H
|
#define BASE_TL_ALGORITHM_H
|
||||||
|
|
||||||
#include "base/tl/range.h"
|
#include "base/tl/range.h"
|
||||||
|
#include <algorithm>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -108,7 +109,7 @@ void sort_quick(R range)
|
||||||
template<class R>
|
template<class R>
|
||||||
void sort(R range)
|
void sort(R range)
|
||||||
{
|
{
|
||||||
sort_bubble(range);
|
std::sort(&range.front(), &range.back() + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class R>
|
template<class R>
|
||||||
|
|
|
@ -15,7 +15,7 @@ public:
|
||||||
char m_aCountryCodeString[8];
|
char m_aCountryCodeString[8];
|
||||||
IGraphics::CTextureHandle m_Texture;
|
IGraphics::CTextureHandle m_Texture;
|
||||||
|
|
||||||
bool operator<(const CCountryFlag &Other) { return str_comp(m_aCountryCodeString, Other.m_aCountryCodeString) < 0; }
|
bool operator<(const CCountryFlag &Other) const { return str_comp(m_aCountryCodeString, Other.m_aCountryCodeString) < 0; }
|
||||||
};
|
};
|
||||||
|
|
||||||
void OnInit();
|
void OnInit();
|
||||||
|
|
|
@ -316,7 +316,7 @@ protected:
|
||||||
const CFriendInfo *m_pFriendInfo;
|
const CFriendInfo *m_pFriendInfo;
|
||||||
int m_NumFound;
|
int m_NumFound;
|
||||||
|
|
||||||
bool operator<(const CFriendItem &Other)
|
bool operator<(const CFriendItem &Other) const
|
||||||
{
|
{
|
||||||
if(m_NumFound && !Other.m_NumFound)
|
if(m_NumFound && !Other.m_NumFound)
|
||||||
return true;
|
return true;
|
||||||
|
@ -473,7 +473,7 @@ public:
|
||||||
CGhostItem() :
|
CGhostItem() :
|
||||||
m_Slot(-1), m_Own(false) { m_aFilename[0] = 0; }
|
m_Slot(-1), m_Own(false) { m_aFilename[0] = 0; }
|
||||||
|
|
||||||
bool operator<(const CGhostItem &Other) { return m_Time < Other.m_Time; }
|
bool operator<(const CGhostItem &Other) const { return m_Time < Other.m_Time; }
|
||||||
|
|
||||||
bool Active() const { return m_Slot != -1; }
|
bool Active() const { return m_Slot != -1; }
|
||||||
bool HasFile() const { return m_aFilename[0]; }
|
bool HasFile() const { return m_aFilename[0]; }
|
||||||
|
|
|
@ -1302,7 +1302,7 @@ public:
|
||||||
string m_FileName;
|
string m_FileName;
|
||||||
int m_CountryCode;
|
int m_CountryCode;
|
||||||
|
|
||||||
bool operator<(const CLanguage &Other) { return m_Name < Other.m_Name; }
|
bool operator<(const CLanguage &Other) const { return m_Name < Other.m_Name; }
|
||||||
};
|
};
|
||||||
|
|
||||||
void LoadLanguageIndexfile(IStorage *pStorage, IConsole *pConsole, sorted_array<CLanguage> *pLanguages)
|
void LoadLanguageIndexfile(IStorage *pStorage, IConsole *pConsole, sorted_array<CLanguage> *pLanguages)
|
||||||
|
|
|
@ -20,10 +20,10 @@ public:
|
||||||
char m_aName[24];
|
char m_aName[24];
|
||||||
ColorRGBA m_BloodColor;
|
ColorRGBA m_BloodColor;
|
||||||
|
|
||||||
bool operator<(const CSkin &Other) { return str_comp(m_aName, Other.m_aName) < 0; }
|
bool operator<(const CSkin &Other) const { return str_comp(m_aName, Other.m_aName) < 0; }
|
||||||
|
|
||||||
bool operator<(const char *pOther) { return str_comp(m_aName, pOther) < 0; }
|
bool operator<(const char *pOther) const { return str_comp(m_aName, pOther) < 0; }
|
||||||
bool operator==(const char *pOther) { return !str_comp(m_aName, pOther); }
|
bool operator==(const char *pOther) const { return !str_comp(m_aName, pOther); }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CDownloadSkin
|
struct CDownloadSkin
|
||||||
|
@ -32,9 +32,9 @@ public:
|
||||||
char m_aPath[MAX_PATH_LENGTH];
|
char m_aPath[MAX_PATH_LENGTH];
|
||||||
char m_aName[24];
|
char m_aName[24];
|
||||||
|
|
||||||
bool operator<(const CDownloadSkin &Other) { return str_comp(m_aName, Other.m_aName) < 0; }
|
bool operator<(const CDownloadSkin &Other) const { return str_comp(m_aName, Other.m_aName) < 0; }
|
||||||
bool operator<(const char *pOther) { return str_comp(m_aName, pOther) < 0; }
|
bool operator<(const char *pOther) const { return str_comp(m_aName, pOther) < 0; }
|
||||||
bool operator==(const char *pOther) { return !str_comp(m_aName, pOther); }
|
bool operator==(const char *pOther) const { return !str_comp(m_aName, pOther); }
|
||||||
};
|
};
|
||||||
|
|
||||||
void OnInit();
|
void OnInit();
|
||||||
|
|
|
@ -881,7 +881,7 @@ public:
|
||||||
int m_StorageType;
|
int m_StorageType;
|
||||||
bool m_IsVisible;
|
bool m_IsVisible;
|
||||||
|
|
||||||
bool operator<(const CFilelistItem &Other) { return !str_comp(m_aFilename, "..") ? true : !str_comp(Other.m_aFilename, "..") ? false : m_IsDir && !Other.m_IsDir ? true : !m_IsDir && Other.m_IsDir ? false : str_comp_nocase(m_aFilename, Other.m_aFilename) < 0; }
|
bool operator<(const CFilelistItem &Other) const { return !str_comp(m_aFilename, "..") ? true : !str_comp(Other.m_aFilename, "..") ? false : m_IsDir && !Other.m_IsDir ? true : !m_IsDir && Other.m_IsDir ? false : str_comp_nocase(m_aFilename, Other.m_aFilename) < 0; }
|
||||||
};
|
};
|
||||||
sorted_array<CFilelistItem> m_FileList;
|
sorted_array<CFilelistItem> m_FileList;
|
||||||
int m_FilesStartAt;
|
int m_FilesStartAt;
|
||||||
|
|
|
@ -347,7 +347,7 @@ struct CEnvPoint
|
||||||
int m_Curvetype;
|
int m_Curvetype;
|
||||||
int m_aValues[4]; // 1-4 depending on envelope (22.10 fixed point)
|
int m_aValues[4]; // 1-4 depending on envelope (22.10 fixed point)
|
||||||
|
|
||||||
bool operator<(const CEnvPoint &Other) { return m_Time < Other.m_Time; }
|
bool operator<(const CEnvPoint &Other) const { return m_Time < Other.m_Time; }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CMapItemEnvelope_v1
|
struct CMapItemEnvelope_v1
|
||||||
|
|
Loading…
Reference in a new issue