Skip to content

Commit 859fe01

Browse files
committed
性能提升(臆测的)
1 parent 92bc53f commit 859fe01

6 files changed

Lines changed: 7 additions & 9 deletions

File tree

src/GccCpp2ObjAction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ bool GccCpp2ObjAction::execute(const DepInfo& info)
3434

3535
string cmd = compile_cpp_cmd;
3636

37-
cmd += compiler_specific_extra_compile_flags[cpp_path];
37+
cmd += compiler_specific_extra_compile_flags[cpp_path.string()];
3838

3939
cmd += " ";
4040
cmd += compile_cmd_include_dirs;

src/VcCpp2ObjAction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ bool VcCpp2ObjAction::execute(const DepInfo& info)
3838
string cmd = R"(")"; // cmd的怪癖,传给system函数的东西,前后还得一个引号。 参考: https://stackoverflow.com/questions/9964865/c-system-not-working-when-there-are-spaces-in-two-different-parameters
3939
cmd += compile_cpp_cmd;
4040

41-
cmd += compiler_specific_extra_compile_flags[cpp_path];
41+
cmd += compiler_specific_extra_compile_flags[cpp_path.string()];
4242

4343
cmd += " ";
4444
cmd += compile_cmd_include_dirs;

src/global.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ bool vc_use_pch = false; // vc是否使用预编译头文件。(目前只支持
6565
fs::path vc_h_to_precompile; // vc需要预编译的头文件。等于headers_to_pc[0]
6666
fs::path vc_cpp_to_generate_pch; // vc用于产生预编译头文件的cpp文件
6767
//string compiler_specific_extra_compile_flags; // 源文件中指定的,编译时用的其他选项
68-
map<fs::path, string> compiler_specific_extra_compile_flags; // 源文件中指定的,编译时用的其他选项。不同文件可能用不同的编译选项
68+
//unordered_map<fs::path, string> compiler_specific_extra_compile_flags; // 源文件中指定的,编译时用的其他选项。不同文件可能用不同的编译选项
69+
unordered_map<string, string> compiler_specific_extra_compile_flags; // 源文件中指定的,编译时用的其他选项。不同文件可能用不同的编译选项
6970
string compiler_specific_extra_link_flags; // 源文件中指定的,链接时用的其他选项
7071

7172

src/global.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ extern bool vc_use_pch;
2727
extern fs::path vc_h_to_precompile;
2828
extern fs::path vc_cpp_to_generate_pch;
2929
//extern string compiler_specific_extra_compile_flags;
30-
extern map<fs::path, string> compiler_specific_extra_compile_flags;
30+
//extern unordered_map<fs::path, string> compiler_specific_extra_compile_flags;
31+
extern unordered_map<string, string> compiler_specific_extra_compile_flags;
3132
extern string compiler_specific_extra_link_flags;
3233
extern string compiler_dir;
3334
extern string compile_cmd_include_dirs;

src/main.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ try {
1111
collect();
1212
if (collect_only) return 0;
1313

14-
// todo: 额外的flags,是各个.cpp文件独立设置?还是?独立设置吧
15-
//compile_cpp_cmd += compiler_specific_extra_compile_flags;
16-
//compile_h_cmd += compiler_specific_extra_compile_flags;
17-
1814
// 构建
1915
bool success = build();
2016
if (!success) return 0;

src/scan.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ void scan(fs::path src_path)
100100
MINILOG(collect_info_logger, "found extra link flags: " << matches[1]);
101101
string flags = " ";
102102
flags += matches[1];
103-
compiler_specific_extra_compile_flags[src_path] += flags;
103+
compiler_specific_extra_compile_flags[src_path.string()] += flags;
104104
}
105105

106106
if (regex_search(line, matches, compiler_specific_extra_link_flags_pat)) {

0 commit comments

Comments
 (0)