Skip to content

Commit 02f04a8

Browse files
committed
tmp
1 parent 4ea784f commit 02f04a8

File tree

3 files changed

+10
-12
lines changed

3 files changed

+10
-12
lines changed

src/node_snapshot_builder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ struct SnapshotData;
1919
class NODE_EXTERN_PRIVATE SnapshotBuilder {
2020
public:
2121
static ExitCode GenerateAsSource(
22-
std::string_view out_path,
22+
const char* out_path,
2323
const std::vector<std::string>& args,
2424
const std::vector<std::string>& exec_args,
2525
std::optional<std::string_view> main_script_path = std::nullopt,

src/node_snapshotable.cc

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -737,27 +737,25 @@ static std::string FormatSize(size_t size) {
737737
}
738738

739739
std::string ToOctalString(const uint8_t ch) {
740-
std::string result;
741740
// We can print most printable characters directly. The exceptions are '\'
742741
// (escape characters), " (would end the string), and ? (trigraphs). The
743742
// latter may be overly conservative: we compile with C++17 which doesn't
744743
// support trigraphs.
745744
if (ch >= ' ' && ch <= '~' && ch != '\\' && ch != '"' && ch != '?') {
746745
return std::string(1, static_cast<char>(ch));
747-
} else {
748-
// All other characters are blindly output as octal.
749-
const char c0 = '0' + ((ch >> 6) & 7);
750-
const char c1 = '0' + ((ch >> 3) & 7);
751-
const char c2 = '0' + (ch & 7);
752-
return std::string("\\") + c0 + c1 + c2;
753746
}
747+
// All other characters are blindly output as octal.
748+
const char c0 = '0' + ((ch >> 6) & 7);
749+
const char c1 = '0' + ((ch >> 3) & 7);
750+
const char c2 = '0' + (ch & 7);
751+
return std::string("\\") + c0 + c1 + c2;
754752
}
755753

756754
std::vector<std::string> GetOctalTable() {
757755
size_t size = 1 << 8;
758756
std::vector<std::string> code_table(size);
759-
for (uint8_t i = 0; i < size; ++i) {
760-
code_table[i] = ToOctalString(i);
757+
for (size_t i = 0; i < size; ++i) {
758+
code_table[i] = ToOctalString(static_cast<uint8_t>(i));
761759
}
762760
return code_table;
763761
}
@@ -1083,7 +1081,7 @@ ExitCode SnapshotBuilder::CreateSnapshot(SnapshotData* out,
10831081
}
10841082

10851083
ExitCode SnapshotBuilder::GenerateAsSource(
1086-
std::string_view out_path,
1084+
const char* out_path,
10871085
const std::vector<std::string>& args,
10881086
const std::vector<std::string>& exec_args,
10891087
std::optional<std::string_view> main_script_path,

tools/snapshot/node_mksnapshot.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ int BuildSnapshot(int argc, char* argv[]) {
8686
#endif
8787

8888
node::ExitCode exit_code =
89-
node::SnapshotBuilder::GenerateAsSource(out_path,
89+
node::SnapshotBuilder::GenerateAsSource(out_path.c_str(),
9090
result->args(),
9191
result->exec_args(),
9292
main_script_path,

0 commit comments

Comments
 (0)