Skip to content

Commit

Permalink
Use std::unordered_map rather than std::map as possible
Browse files Browse the repository at this point in the history
  • Loading branch information
vain0x committed Dec 5, 2015
1 parent f5c6f28 commit b275105
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/CVardataString.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class CVardataStrWriter
{
private:
std::unique_ptr<CStructedStrWriter> writer_;
mutable std::map<void const*, string> visited_;
mutable unordered_map<void const*, string> visited_;

public:
CVardataStrWriter(CVardataStrWriter&& src);
Expand Down
4 changes: 2 additions & 2 deletions src/VTNodeModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ struct VTNodeModule::Private
VTNodeModule& self;
VTNodeData* const parent_;
string const name_;
std::map<string, shared_ptr<VTNodeVar>> vars_;
std::map<string, shared_ptr<VTNodeModule>> modules_;
unordered_map<string, shared_ptr<VTNodeVar>> vars_;
unordered_map<string, shared_ptr<VTNodeModule>> modules_;

public:
void insertVar(char const* name);
Expand Down
5 changes: 2 additions & 3 deletions src/VTNodeScript.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

#include <unordered_set>
#include <unordered_map>
#include "main.h"
#include "VarTreeNodeData.h"
#include "config_mng.h"
Expand All @@ -11,8 +10,8 @@ struct VTNodeScript::Impl
bool resolutionDone_;

std::unordered_set<string> userDirs_;
std::unordered_map<string, shared_ptr<string const>> fullPathFromRefName_;
std::map<string const, LineDelimitedString> cache_;
unordered_map<string, shared_ptr<string const>> fullPathFromRefName_;
unordered_map<string, LineDelimitedString> cache_;

public:
auto searchFile(string const& fileName)->shared_ptr<string const>;
Expand Down
3 changes: 1 addition & 2 deletions src/config_mng.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

#include <string>
#include <array>
#include <map>
#include <memory>
#include "module/Singleton.h"
#include "module/handle_deleter.hpp"
Expand Down Expand Up @@ -61,7 +60,7 @@ struct KnowbugConfig : public Singleton<KnowbugConfig>
bool bResultNode;
bool bCustomDraw;
std::array<COLORREF, HSPVAR_FLAG_USERDEF> clrText;
std::map<string, COLORREF> clrTextExtra;
unordered_map<string, COLORREF> clrTextExtra;
std::vector<VswInfo> vswInfo;
string logPath;
bool warnsBeforeClearingLog;
Expand Down
3 changes: 2 additions & 1 deletion src/hpiutil/dinfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#pragma once

#include <map>
#include <unordered_map>
#include <unordered_set>
#include "hpiutil.hpp"

Expand All @@ -25,7 +26,7 @@ class DInfo
static DInfo& instance();

private:
using ident_table_t = std::map<int, char const*>;
using ident_table_t = std::unordered_map<int, char const*>;
using cs_map_t = std::map<std::pair<char const*, int>, csptr_t>;

std::unordered_set<std::string> fileRefNames_;
Expand Down
6 changes: 6 additions & 0 deletions src/knowbug.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<AdditionalIncludeDirectories>hpiutil/hspsdk;../hpimod;../hpimod/hspsdk;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
</ClCompile>
<Link>
<OutputFile>$(OutDir)hsp3debug.dll</OutputFile>
Expand Down Expand Up @@ -171,6 +172,7 @@ copy $(TargetPath) D:\Tool\hsp\$(TargetFileName)
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<AdditionalIncludeDirectories>hpiutil/hspsdk;../hpimod;../hpimod/hspsdk;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
</ClCompile>
<Link>
<OutputFile>$(OutDir)$(TargetFileName)</OutputFile>
Expand Down Expand Up @@ -202,6 +204,7 @@ copy $(TargetPath) D:\Tool\hsp\$(TargetFileName)
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<AdditionalIncludeDirectories>hpiutil/hspsdk;../hpimod;../hpimod/hspsdk;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
</ClCompile>
<Link>
<OutputFile>$(OutDir)hsp3debug.dll</OutputFile>
Expand Down Expand Up @@ -235,6 +238,7 @@ copy $(TargetPath) D:\Tool\hsp\$(TargetFileName)
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<AdditionalIncludeDirectories>hpiutil/hspsdk;../hpimod;../hpimod/hspsdk;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
</ClCompile>
<Link>
<OutputFile>$(OutDir)$(TargetFileName)</OutputFile>
Expand Down Expand Up @@ -264,6 +268,7 @@ copy $(TargetPath) D:\Tool\hsp\$(TargetFileName)
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<Optimization>Full</Optimization>
<AdditionalIncludeDirectories>hpiutil/hspsdk;../hpimod;../hpimod/hspsdk;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
</ClCompile>
<Link>
<OutputFile>$(OutDir)hsp3debug.dll</OutputFile>
Expand Down Expand Up @@ -297,6 +302,7 @@ copy $(TargetPath) D:\Tool\hsp\$(TargetFileName)
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<Optimization>Full</Optimization>
<AdditionalIncludeDirectories>hpiutil/hspsdk;../hpimod;../hpimod/hspsdk;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
</ClCompile>
<Link>
<OutputFile>$(OutDir)$(TargetFileName)</OutputFile>
Expand Down
4 changes: 2 additions & 2 deletions src/module/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
#include <string>
#include <array>
#include <vector>
#include <map>
#include <unordered_map>
#include <functional>
#include "pair_range.hpp"
#include "range_all.hpp"

using std::string;
using std::vector;
using std::map;
using std::unordered_map;
using std::shared_ptr;
using std::unique_ptr;

Expand Down
6 changes: 3 additions & 3 deletions src/vartree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ struct VTView::Impl
{
VTView& self_;

std::map<VTNodeData const*, HTREEITEM> itemFromNode_;
unordered_map<VTNodeData const*, HTREEITEM> itemFromNode_;

//ノードの文字列のキャッシュ (停止中の間のみ有効)
std::map<HTREEITEM, shared_ptr<string const>> textCache_;
unordered_map<HTREEITEM, shared_ptr<string const>> textCache_;

//ノードごとのビューウィンドウのキャレット位置
std::map<HTREEITEM, int> viewCaret_;
unordered_map<HTREEITEM, int> viewCaret_;

shared_ptr<TvObserver> observer_;

Expand Down

0 comments on commit b275105

Please sign in to comment.