From 8e99b342a40429449e98e3f5f7ccfdb07aa4ddb5 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sun, 25 Aug 2013 12:19:10 -0700 Subject: [PATCH] Switch ClientPrefs off KTrie (bug 5884 part 15, r=ds). --- core/AdminCache.cpp | 2 +- core/AdminCache.h | 2 +- extensions/clientprefs/cookie.cpp | 10 ++++------ extensions/clientprefs/cookie.h | 12 ++++++++---- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/core/AdminCache.cpp b/core/AdminCache.cpp index 688549bc..fdc844f8 100644 --- a/core/AdminCache.cpp +++ b/core/AdminCache.cpp @@ -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. diff --git a/core/AdminCache.h b/core/AdminCache.h index c7d21da1..3d08089b 100644 --- a/core/AdminCache.h +++ b/core/AdminCache.h @@ -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. diff --git a/extensions/clientprefs/cookie.cpp b/extensions/clientprefs/cookie.cpp index ca38de5b..f8a092ac 100644 --- a/extensions/clientprefs/cookie.cpp +++ b/extensions/clientprefs/cookie.cpp @@ -67,12 +67,10 @@ void CookieManager::Unload() Cookie *CookieManager::FindCookie(const char *name) { - Cookie **pCookie = cookieTrie.retrieve(name); - - if (pCookie == NULL) + Cookie *cookie; + if (!cookieFinder.retrieve(name, &cookie)) return NULL; - - return *pCookie; + return cookie; } Cookie *CookieManager::CreateCookie(const char *name, const char *description, CookieAccess access) @@ -96,7 +94,7 @@ Cookie *CookieManager::CreateCookie(const char *name, const char *description, C TQueryOp *op = new TQueryOp(Query_InsertCookie, pCookie); op->m_params.cookie = pCookie; - cookieTrie.insert(name, pCookie); + cookieFinder.insert(name, pCookie); cookieList.push_back(pCookie); g_ClientPrefs.AddQueryToQueue(op); diff --git a/extensions/clientprefs/cookie.h b/extensions/clientprefs/cookie.h index c678d392..d8916c96 100644 --- a/extensions/clientprefs/cookie.h +++ b/extensions/clientprefs/cookie.h @@ -1,5 +1,5 @@ /** - * vim: set ts=4 : + * vim: set ts=4 sw=4 tw=99 noet : * ============================================================================= * SourceMod Client Preferences Extension * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. @@ -34,8 +34,7 @@ #include "extension.h" #include "sh_list.h" -#include "sm_trie_tpl.h" - +#include #define MAX_NAME_LENGTH 30 #define MAX_DESC_LENGTH 255 @@ -92,6 +91,11 @@ struct Cookie int dbid; CookieData *data[MAXCLIENTS+1]; CookieAccess access; + + static inline bool matches(const char *name, const Cookie *cookie) + { + return strcmp(name, cookie->name) == 0; + } }; class CookieManager : public IClientListener, public IPluginsListener @@ -128,7 +132,7 @@ public: IBaseMenu *clientMenu; private: - KTrie cookieTrie; + NameHashSet cookieFinder; SourceHook::List clientData[MAXCLIENTS+1]; bool connected[MAXCLIENTS+1];