Performance: Simple upgrade/cleanup of stl c++11 containers (10% perf. increase).

This commit is contained in:
John Kessenich 2015-07-18 22:34:27 -06:00
parent f4673162b7
commit 2f273369e4
10 changed files with 58 additions and 54 deletions

View file

@ -130,7 +130,7 @@ namespace glslang {
//
int TPpContext::LookUpAddString(const char* s)
{
TAtomMap::const_iterator it = atomMap.find(s);
auto it = atomMap.find(s);
if (it == atomMap.end())
return AddAtomFixed(s, nextAtom++);
else
@ -161,7 +161,7 @@ const char* TPpContext::GetAtomString(int atom)
//
int TPpContext::AddAtomFixed(const char* s, int atom)
{
TAtomMap::const_iterator it = atomMap.insert(std::pair<TString, int>(s, atom)).first;
auto it = atomMap.insert(std::pair<TString, int>(s, atom)).first;
if (stringMap.size() < (size_t)atom + 1)
stringMap.resize(atom + 100, 0);
stringMap[atom] = &it->first;

View file

@ -78,6 +78,8 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef PPCONTEXT_H
#define PPCONTEXT_H
#include <unordered_map>
#include "../ParseHelper.h"
#pragma warning(disable : 4127)
@ -190,7 +192,7 @@ public:
};
MemoryPool *pool;
typedef std::map<int, Symbol*> TSymbolMap;
typedef TUnorderedMap<int, Symbol*> TSymbolMap;
TSymbolMap symbols; // this has light use... just defined macros
protected:
@ -459,7 +461,7 @@ protected:
//
// From PpAtom.cpp
//
typedef std::map<const TString, int> TAtomMap;
typedef TUnorderedMap<const TString, int, TStringHash> TAtomMap;
typedef TVector<const TString*> TStringMap;
TAtomMap atomMap;
TStringMap stringMap;