Switch ShareSys off KTrie (bug 5884 part 5, r=ds).

This commit is contained in:
David Anderson 2013-08-25 11:59:47 -07:00
parent a8ab617ee9
commit ebe9ee8114
2 changed files with 23 additions and 22 deletions

View File

@ -1,5 +1,5 @@
/**
* vim: set ts=4 :
* vim: set ts=4 sw=4 tw=99 noet :
* =============================================================================
* SourceMod
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
@ -287,14 +287,10 @@ void ShareSystem::OverrideNatives(IExtension *myself, const sp_nativeinfo_t *nat
NativeEntry *ShareSystem::FindNative(const char *name)
{
NativeEntry **ppEntry;
if ((ppEntry = m_NtvCache.retrieve(name)) == NULL)
{
NativeEntry *entry;
if (!m_NtvCache.retrieve(name, &entry))
return NULL;
}
return *ppEntry;
return entry;
}
void ShareSystem::BindNativesToPlugin(CPlugin *pPlugin, bool bCoreOnly)
@ -531,7 +527,7 @@ NativeEntry *ShareSystem::AddFakeNative(IPluginFunction *pFunc, const char *name
void ShareSystem::AddCapabilityProvider(IExtension *myself, IFeatureProvider *provider,
const char *name)
{
if (m_caps.retrieve(name) != NULL)
if (m_caps.contains(name))
return;
Capability cap;
@ -544,14 +540,13 @@ void ShareSystem::AddCapabilityProvider(IExtension *myself, IFeatureProvider *pr
void ShareSystem::DropCapabilityProvider(IExtension *myself, IFeatureProvider *provider,
const char *name)
{
Capability *pCap = m_caps.retrieve(name);
if (pCap == NULL)
StringHashMap<Capability>::Result r = m_caps.find(name);
if (!r.found())
return;
if (r->value.ext != myself || r->value.provider != provider)
return;
if (pCap->ext != myself || pCap->provider != provider)
return;
m_caps.remove(name);
m_caps.remove(r);
}
FeatureStatus ShareSystem::TestFeature(IPluginRuntime *pRuntime, FeatureType feature,
@ -603,9 +598,9 @@ FeatureStatus ShareSystem::TestNative(IPluginRuntime *pRuntime, const char *name
FeatureStatus ShareSystem::TestCap(const char *name)
{
Capability *cap = m_caps.retrieve(name);
if (cap == NULL)
StringHashMap<Capability>::Result r = m_caps.find(name);
if (!r.found())
return FeatureStatus_Unknown;
return cap->provider->GetFeatureStatus(FeatureType_Capability, name);
return r->value.provider->GetFeatureStatus(FeatureType_Capability, name);
}

View File

@ -1,5 +1,5 @@
/**
* vim: set ts=4 :
* vim: set ts=4 sw=4 tw=99 noet :
* =============================================================================
* SourceMod
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
@ -35,7 +35,8 @@
#include <IShareSys.h>
#include <IHandleSys.h>
#include <sh_list.h>
#include <sm_trie_tpl.h>
#include <sm_stringhashmap.h>
#include <sm_namehashset.h>
#include "common_logic.h"
using namespace SourceHook;
@ -84,6 +85,11 @@ struct NativeEntry
const char *name;
ReplaceNative replacement;
FakeNative *fake;
static inline bool matches(const char *name, const NativeEntry *entry)
{
return strcmp(name, entry->name) == 0;
}
};
struct Capability
@ -154,8 +160,8 @@ private:
IdentityToken_t m_IdentRoot;
HandleType_t m_IfaceType;
IdentityType_t m_CoreType;
KTrie<NativeEntry *> m_NtvCache;
KTrie<Capability> m_caps;
NameHashSet<NativeEntry *> m_NtvCache;
StringHashMap<Capability> m_caps;
};
extern ShareSystem g_ShareSys;