Switch Profiler off KTrie (bug 5884 part 6, r=ds).
Switch Profiler off KTrie (
bug 5884 part 6, r=ds).
1.1 --- a/core/logic/Profiler.cpp Sun Aug 25 11:59:47 2013 -0700
1.2 +++ b/core/logic/Profiler.cpp Sun Aug 25 11:59:48 2013 -0700
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * vim: set ts=4 :
1.6 + * vim: set ts=4 sw=4 tw=99 noet :
1.7 * =============================================================================
1.8 * SourceMod
1.9 * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
1.10 @@ -465,7 +465,7 @@
1.11 {
1.12 double atom_time;
1.13 char full_name[256];
1.14 - prof_atom_report_t **pReport, *report;
1.15 + prof_atom_report_t *report;
1.16
1.17 if (atom.atom_type == SP_PROF_NATIVES)
1.18 {
1.19 @@ -487,7 +487,7 @@
1.20
1.21 atom_time = CalcAtomTime(atom);
1.22
1.23 - if ((pReport = m_ReportLookup.retrieve(full_name)) == NULL)
1.24 + if (!m_ReportLookup.retrieve(full_name, &report))
1.25 {
1.26 report = new prof_atom_report_t;
1.27
1.28 @@ -502,8 +502,6 @@
1.29 }
1.30 else
1.31 {
1.32 - report = *pReport;
1.33 -
1.34 if (atom_time > report->max_time)
1.35 {
1.36 report->max_time = atom_time;
2.1 --- a/core/logic/Profiler.h Sun Aug 25 11:59:47 2013 -0700
2.2 +++ b/core/logic/Profiler.h Sun Aug 25 11:59:48 2013 -0700
2.3 @@ -1,5 +1,5 @@
2.4 /**
2.5 - * vim: set ts=4 :
2.6 + * vim: set ts=4 sw=4 tw=99 noet :
2.7 * =============================================================================
2.8 * SourceMod
2.9 * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
2.10 @@ -34,9 +34,9 @@
2.11
2.12 #include <sp_vm_api.h>
2.13 #include <sm_platform.h>
2.14 -#include <sm_trie_tpl.h>
2.15 #include <sh_vector.h>
2.16 #include <sh_stack.h>
2.17 +#include <sm_namehashset.h>
2.18 #include <stdio.h>
2.19 #include "common_logic.h"
2.20 #include <IRootConsoleMenu.h>
2.21 @@ -72,6 +72,11 @@
2.22 unsigned int num_calls; /* Number of invocations */
2.23 double min_time; /* Min time spent in one call, in s */
2.24 double max_time; /* Max time spent in one call, in s */
2.25 +
2.26 + static inline bool matches(const char *name, const prof_atom_report_t *report)
2.27 + {
2.28 + return strcmp(report->atom_name, name) == 0;
2.29 + }
2.30 };
2.31
2.32 class ProfileReport
2.33 @@ -84,7 +89,7 @@
2.34 prof_atom_report_t *GetReport(size_t i);
2.35 void Clear();
2.36 private:
2.37 - KTrie<prof_atom_report_t *> m_ReportLookup;
2.38 + NameHashSet<prof_atom_report_t *> m_ReportLookup;
2.39 CVector<prof_atom_report_t *> m_Reports;
2.40 };
2.41