Switch ShareSys off KTrie (bug 5884 part 5, r=ds).
This commit is contained in:
		
							parent
							
								
									a8ab617ee9
								
							
						
					
					
						commit
						ebe9ee8114
					
				@ -1,5 +1,5 @@
 | 
				
			|||||||
/**
 | 
					/**
 | 
				
			||||||
 * vim: set ts=4 :
 | 
					 * vim: set ts=4 sw=4 tw=99 noet :
 | 
				
			||||||
 * =============================================================================
 | 
					 * =============================================================================
 | 
				
			||||||
 * SourceMod
 | 
					 * SourceMod
 | 
				
			||||||
 * Copyright (C) 2004-2008 AlliedModders LLC.  All rights reserved.
 | 
					 * 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 *ShareSystem::FindNative(const char *name)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	NativeEntry **ppEntry;
 | 
						NativeEntry *entry;
 | 
				
			||||||
 | 
						if (!m_NtvCache.retrieve(name, &entry))
 | 
				
			||||||
	if ((ppEntry = m_NtvCache.retrieve(name)) == NULL)
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		return NULL;
 | 
							return NULL;
 | 
				
			||||||
	}
 | 
						return entry;
 | 
				
			||||||
 | 
					 | 
				
			||||||
	return *ppEntry;
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void ShareSystem::BindNativesToPlugin(CPlugin *pPlugin, bool bCoreOnly)
 | 
					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,
 | 
					void ShareSystem::AddCapabilityProvider(IExtension *myself, IFeatureProvider *provider,
 | 
				
			||||||
		                                const char *name)
 | 
							                                const char *name)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	if (m_caps.retrieve(name) != NULL)
 | 
						if (m_caps.contains(name))
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	Capability cap;
 | 
						Capability cap;
 | 
				
			||||||
@ -544,14 +540,13 @@ void ShareSystem::AddCapabilityProvider(IExtension *myself, IFeatureProvider *pr
 | 
				
			|||||||
void ShareSystem::DropCapabilityProvider(IExtension *myself, IFeatureProvider *provider,
 | 
					void ShareSystem::DropCapabilityProvider(IExtension *myself, IFeatureProvider *provider,
 | 
				
			||||||
		                                 const char *name)
 | 
							                                 const char *name)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	Capability *pCap = m_caps.retrieve(name);
 | 
						StringHashMap<Capability>::Result r = m_caps.find(name);
 | 
				
			||||||
	if (pCap == NULL)
 | 
						if (!r.found())
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
 | 
						if (r->value.ext != myself || r->value.provider != provider)
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (pCap->ext != myself || pCap->provider != provider)
 | 
						m_caps.remove(r);
 | 
				
			||||||
		return;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	m_caps.remove(name);
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
FeatureStatus ShareSystem::TestFeature(IPluginRuntime *pRuntime, FeatureType feature, 
 | 
					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)
 | 
					FeatureStatus ShareSystem::TestCap(const char *name)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	Capability *cap = m_caps.retrieve(name);
 | 
						StringHashMap<Capability>::Result r = m_caps.find(name);
 | 
				
			||||||
	if (cap == NULL)
 | 
						if (!r.found())
 | 
				
			||||||
		return FeatureStatus_Unknown;
 | 
							return FeatureStatus_Unknown;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return cap->provider->GetFeatureStatus(FeatureType_Capability, name);
 | 
						return r->value.provider->GetFeatureStatus(FeatureType_Capability, name);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -1,5 +1,5 @@
 | 
				
			|||||||
/**
 | 
					/**
 | 
				
			||||||
 * vim: set ts=4 :
 | 
					 * vim: set ts=4 sw=4 tw=99 noet :
 | 
				
			||||||
 * =============================================================================
 | 
					 * =============================================================================
 | 
				
			||||||
 * SourceMod
 | 
					 * SourceMod
 | 
				
			||||||
 * Copyright (C) 2004-2008 AlliedModders LLC.  All rights reserved.
 | 
					 * Copyright (C) 2004-2008 AlliedModders LLC.  All rights reserved.
 | 
				
			||||||
@ -35,7 +35,8 @@
 | 
				
			|||||||
#include <IShareSys.h>
 | 
					#include <IShareSys.h>
 | 
				
			||||||
#include <IHandleSys.h>
 | 
					#include <IHandleSys.h>
 | 
				
			||||||
#include <sh_list.h>
 | 
					#include <sh_list.h>
 | 
				
			||||||
#include <sm_trie_tpl.h>
 | 
					#include <sm_stringhashmap.h>
 | 
				
			||||||
 | 
					#include <sm_namehashset.h>
 | 
				
			||||||
#include "common_logic.h"
 | 
					#include "common_logic.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
using namespace SourceHook;
 | 
					using namespace SourceHook;
 | 
				
			||||||
@ -84,6 +85,11 @@ struct NativeEntry
 | 
				
			|||||||
	const char *name;
 | 
						const char *name;
 | 
				
			||||||
	ReplaceNative replacement;
 | 
						ReplaceNative replacement;
 | 
				
			||||||
	FakeNative *fake;
 | 
						FakeNative *fake;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						static inline bool matches(const char *name, const NativeEntry *entry)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							return strcmp(name, entry->name) == 0;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct Capability
 | 
					struct Capability
 | 
				
			||||||
@ -154,8 +160,8 @@ private:
 | 
				
			|||||||
	IdentityToken_t m_IdentRoot;
 | 
						IdentityToken_t m_IdentRoot;
 | 
				
			||||||
	HandleType_t m_IfaceType;
 | 
						HandleType_t m_IfaceType;
 | 
				
			||||||
	IdentityType_t m_CoreType;
 | 
						IdentityType_t m_CoreType;
 | 
				
			||||||
	KTrie<NativeEntry *> m_NtvCache;
 | 
						NameHashSet<NativeEntry *> m_NtvCache;
 | 
				
			||||||
	KTrie<Capability> m_caps;
 | 
						StringHashMap<Capability> m_caps;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern ShareSystem g_ShareSys;
 | 
					extern ShareSystem g_ShareSys;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user