Skip to content

Commit 80acff8

Browse files
committed
Replace ke::LinkedList with std::list.
1 parent d5d4d78 commit 80acff8

7 files changed

Lines changed: 37 additions & 38 deletions

File tree

core/ConCmdManager.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ using namespace ke;
4545

4646
ConCmdManager g_ConCmds;
4747

48-
typedef ke::LinkedList<CmdHook *> PluginHookList;
48+
typedef std::list<CmdHook *> PluginHookList;
4949
void RegisterInPlugin(CmdHook *hook);
5050

5151
ConCmdManager::ConCmdManager()
@@ -381,7 +381,7 @@ bool ConCmdManager::AddAdminCommand(IPluginFunction *pFunction,
381381
pHook->admin->eflags = pHook->admin->flags;
382382
pInfo->eflags = pHook->admin->eflags;
383383

384-
cmdgroup->hooks.append(pHook);
384+
cmdgroup->hooks.push_back(pHook);
385385
pInfo->hooks.append(pHook);
386386
RegisterInPlugin(pHook);
387387
return true;
@@ -426,13 +426,13 @@ void RegisterInPlugin(CmdHook *hook)
426426
const char *cmd = (*iter)->info->pCmd->GetName();
427427
if (strcmp(orig, cmd) < 0)
428428
{
429-
pList->insertBefore(iter, hook);
429+
pList->emplace(iter, hook);
430430
return;
431431
}
432432
iter++;
433433
}
434434

435-
pList->append(hook);
435+
pList->emplace_back(hook);
436436
}
437437

438438
void ConCmdManager::AddToCmdList(ConCmdInfo *info)

core/ConCmdManager.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,14 @@
3232
#ifndef _INCLUDE_SOURCEMOD_CONCMDMANAGER_H_
3333
#define _INCLUDE_SOURCEMOD_CONCMDMANAGER_H_
3434

35+
#include <list>
3536
#include <memory>
3637

38+
#include <am-inlinelist.h>
39+
#include <am-refcounting.h>
40+
#include <am-utility.h>
41+
#include <sm_stringhashmap.h>
42+
3743
#include "sm_globals.h"
3844
#include "sourcemm_api.h"
3945
#include <IForwardSys.h>
@@ -43,11 +49,6 @@
4349
#include <IAdminSystem.h>
4450
#include "concmd_cleaner.h"
4551
#include "GameHooks.h"
46-
#include <sm_stringhashmap.h>
47-
#include <am-utility.h>
48-
#include <am-inlinelist.h>
49-
#include <am-linkedlist.h>
50-
#include <am-refcounting.h>
5152

5253
using namespace SourceHook;
5354

@@ -56,7 +57,7 @@ struct ConCmdInfo;
5657

5758
struct CommandGroup : public ke::Refcounted<CommandGroup>
5859
{
59-
ke::LinkedList<CmdHook *> hooks;
60+
std::list<CmdHook *> hooks;
6061
};
6162

6263
struct AdminCmdInfo

core/logic/ForwardSys.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ IForward *CForwardManager::CreateForward(const char *name, ExecType et, unsigned
6161
{
6262
scripts->AddFunctionsToForward(name, fwd);
6363

64-
m_managed.append(fwd);
64+
m_managed.push_back(fwd);
6565
}
6666

6767
return fwd;
@@ -78,7 +78,7 @@ IChangeableForward *CForwardManager::CreateForwardEx(const char *name, ExecType
7878

7979
if (fwd)
8080
{
81-
m_unmanaged.append(fwd);
81+
m_unmanaged.push_back(fwd);
8282
}
8383

8484
return fwd;
@@ -751,9 +751,9 @@ bool CForward::AddFunction(IPluginFunction *func)
751751
return false;
752752

753753
if (func->IsRunnable())
754-
m_functions.append(func);
754+
m_functions.push_back(func);
755755
else
756-
m_paused.append(func);
756+
m_paused.push_back(func);
757757

758758
return true;
759759
}
@@ -780,7 +780,7 @@ const char *CForward::GetForwardName()
780780

781781
unsigned int CForward::GetFunctionCount()
782782
{
783-
return m_functions.length();
783+
return m_functions.size();
784784
}
785785

786786
ExecType CForward::GetExecType()

core/logic/NativeOwner.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333

3434
#include <sp_vm_types.h>
3535
#include <sh_list.h>
36-
#include <am-linkedlist.h>
3736
#include <am-vector.h>
3837
#include "common_logic.h"
3938
#include "Native.h"

core/logic/PluginSys.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
#include "Logger.h"
4646
#include "frame_tasks.h"
4747
#include <amtl/am-string.h>
48-
#include <amtl/am-linkedlist.h>
4948
#include <bridge/include/IVEngineServerBridge.h>
5049
#include <bridge/include/CoreProvider.h>
5150

@@ -790,7 +789,7 @@ void CPlugin::BindFakeNativesTo(CPlugin *other)
790789
CPluginManager::CPluginIterator::CPluginIterator(ReentrantList<CPlugin *>& in)
791790
{
792791
for (PluginIter iter(in); !iter.done(); iter.next())
793-
mylist.append(*iter);
792+
mylist.push_back(*iter);
794793
current = mylist.begin();
795794
g_PluginSys.AddPluginsListener(this);
796795
}
@@ -1033,7 +1032,7 @@ void CPluginManager::LoadAutoPlugin(const char *plugin)
10331032

10341033
void CPluginManager::AddPlugin(CPlugin *pPlugin)
10351034
{
1036-
m_plugins.append(pPlugin);
1035+
m_plugins.push_back(pPlugin);
10371036
m_LoadLookup.insert(pPlugin->GetFilename(), pPlugin);
10381037

10391038
pPlugin->SetRegistered();
@@ -1536,12 +1535,12 @@ CPlugin *CPluginManager::GetPluginByCtx(const sp_context_t *ctx)
15361535

15371536
unsigned int CPluginManager::GetPluginCount()
15381537
{
1539-
return m_plugins.length();
1538+
return m_plugins.size();
15401539
}
15411540

15421541
void CPluginManager::AddPluginsListener(IPluginsListener *listener)
15431542
{
1544-
m_listeners.append(listener);
1543+
m_listeners.push_back(listener);
15451544
}
15461545

15471546
void CPluginManager::RemovePluginsListener(IPluginsListener *listener)
@@ -1715,7 +1714,7 @@ void CPluginManager::OnRootConsoleCommand(const char *cmdname, const ICommandArg
17151714
rootmenu->ConsolePrint("[SM] Listing %d plugin%s:", plnum, (plnum > 1) ? "s" : "");
17161715
}
17171716

1718-
ke::LinkedList<CPlugin *> fail_list;
1717+
std::list<CPlugin *> fail_list;
17191718

17201719
for (PluginIter iter(m_plugins); !iter.done(); iter.next(), id++) {
17211720
CPlugin *pl = (*iter);
@@ -1727,7 +1726,7 @@ void CPluginManager::OnRootConsoleCommand(const char *cmdname, const ICommandArg
17271726
len += ke::SafeSprintf(buffer, sizeof(buffer), " %0*d <%s>", plpadding, id, GetStatusText(pl->GetDisplayStatus()));
17281727

17291728
/* Plugin has failed to load. */
1730-
fail_list.append(pl);
1729+
fail_list.push_back(pl);
17311730
}
17321731
else
17331732
{
@@ -2351,7 +2350,7 @@ class OldPluginAPI final : public IPluginManager
23512350
{
23522351
ke::RefPtr<PluginsListenerV1Wrapper> wrapper = new PluginsListenerV1Wrapper(listener);
23532352

2354-
v1_wrappers_.append(wrapper);
2353+
v1_wrappers_.push_back(wrapper);
23552354
g_PluginSys.AddPluginsListener(wrapper);
23562355
}
23572356

core/logic/PluginSys.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,8 @@ class CPluginManager :
320320
void Release();
321321
void OnPluginDestroyed(IPlugin *plugin) override;
322322
private:
323-
ke::LinkedList<CPlugin *> mylist;
324-
ke::LinkedList<CPlugin *>::iterator current;
323+
std::list<CPlugin *> mylist;
324+
std::list<CPlugin *>::iterator current;
325325
};
326326
friend class CPluginManager::CPluginIterator;
327327
public: //IScriptManager
@@ -476,7 +476,7 @@ class CPluginManager :
476476
private:
477477
ReentrantList<IPluginsListener *> m_listeners;
478478
ReentrantList<CPlugin *> m_plugins;
479-
ke::LinkedList<CPluginIterator *> m_iterators;
479+
std::list<CPluginIterator *> m_iterators;
480480

481481
typedef decltype(m_listeners)::iterator ListenerIter;
482482
typedef decltype(m_plugins)::iterator PluginIter;

public/ReentrantList.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,15 @@
2727
#ifndef _include_sourcemod_reentrant_iterator_h_
2828
#define _include_sourcemod_reentrant_iterator_h_
2929

30+
#include <algorithm>
31+
#include <list>
3032
#include <utility>
3133

32-
#include <amtl/am-linkedlist.h>
3334
#include <amtl/am-function.h>
3435

3536
namespace SourceMod {
3637

37-
// ReentrantList is a wrapper around a LinkedList, with special attention twoard
38+
// ReentrantList is a wrapper around a std::list, with special attention twoard
3839
// reentrancy. The list may be mutated during iteration as long as its iterator
3940
// protocol is obeyed: iterators may only be used on the stack in a LIFO manner,
4041
// and it is illegal to request access to an iterator's item after the list has
@@ -43,16 +44,15 @@ namespace SourceMod {
4344
// We guard against this using assertions. If an item in a list is removed, and
4445
// this affects any active iterators, those iterators cannot be used until their
4546
// next() function is called.
46-
template <typename T, class AllocPolicy = ke::SystemAllocatorPolicy>
47-
class ReentrantList : public ke::LinkedList<T, AllocPolicy>
47+
template <typename T>
48+
class ReentrantList : public std::list<T>
4849
{
49-
typedef typename ke::LinkedList<T> BaseType;
50-
typedef typename ke::LinkedList<T>::iterator BaseTypeIter;
50+
typedef typename std::list<T> BaseType;
51+
typedef typename std::list<T>::iterator BaseTypeIter;
5152

5253
public:
53-
ReentrantList(AllocPolicy ap = AllocPolicy())
54-
: ke::LinkedList<T, AllocPolicy>(ap),
55-
top_(nullptr)
54+
ReentrantList()
55+
: top_(nullptr)
5656
{
5757
}
5858

@@ -150,12 +150,12 @@ class ReentrantList : public ke::LinkedList<T, AllocPolicy>
150150

151151
template <typename U>
152152
void insertBefore(iterator& where, U &&obj) {
153-
BaseType::insertBefore(where.impl_, std::forward<U>(obj));
153+
BaseType::insert(where.impl_, std::forward<U>(obj));
154154
}
155155

156156
template <typename U>
157157
bool contains(const U &obj) {
158-
return BaseType::find(obj) != BaseType::end();
158+
return std::find(BaseType::begin(), BaseType::end(), obj) != BaseType::end();
159159
}
160160

161161
private:

0 commit comments

Comments
 (0)