From 1ea4a77c6ccd2c783aedb2ccaf76f46b018c12c5 Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Wed, 2 May 2018 11:45:15 -0700 Subject: Replaced calls to tensorflow::StringPiece::ToString with std::string conversions. That is, instances of sp.ToString() are replaced with std::string(sp). This will allow tensorflow::StringPiece::ToString to be removed, which is necessary before it can be replaced with absl::string_view. PiperOrigin-RevId: 195126422 --- tensorflow/core/kernels/gpu_utils.h | 3 +- .../core/kernels/merge_v2_checkpoints_op_test.cc | 2 +- .../kernels/remote_fused_graph_execute_utils.cc | 32 ++++----- tensorflow/core/kernels/save_restore_v2_ops.cc | 4 +- tensorflow/core/kernels/string_strip_op.cc | 2 +- tensorflow/core/kernels/tensor_array_ops.cc | 2 +- tensorflow/core/kernels/whole_file_read_ops.cc | 2 +- tensorflow/core/lib/strings/numbers.h | 4 +- tensorflow/core/lib/strings/scanner_test.cc | 82 +++++++++++----------- tensorflow/core/lib/strings/str_util.cc | 4 +- tensorflow/core/lib/strings/str_util.h | 2 +- tensorflow/core/platform/env.cc | 4 +- tensorflow/core/platform/env_test.cc | 2 +- tensorflow/core/platform/file_system.cc | 2 +- tensorflow/core/platform/file_system_helper.cc | 2 +- tensorflow/core/platform/file_system_test.cc | 2 +- tensorflow/core/util/command_line_flags.cc | 2 +- tensorflow/core/util/env_var.cc | 8 +-- tensorflow/core/util/example_proto_fast_parsing.cc | 2 +- 19 files changed, 82 insertions(+), 81 deletions(-) diff --git a/tensorflow/core/kernels/gpu_utils.h b/tensorflow/core/kernels/gpu_utils.h index 2f64619afc..c7dbefa0b4 100644 --- a/tensorflow/core/kernels/gpu_utils.h +++ b/tensorflow/core/kernels/gpu_utils.h @@ -123,7 +123,8 @@ class AutoTuneMap { string GetActionSummary(StringPiece action, const Parameters& params, const Config& config) { return strings::Printf("autotune_map %s %s: %s -> (%s)", name_.c_str(), - action.ToString().c_str(), params.ToString().c_str(), + std::string(action).c_str(), + params.ToString().c_str(), config.ToString().c_str()); } diff --git a/tensorflow/core/kernels/merge_v2_checkpoints_op_test.cc b/tensorflow/core/kernels/merge_v2_checkpoints_op_test.cc index 3b9e9e9b75..10e468ce46 100644 --- a/tensorflow/core/kernels/merge_v2_checkpoints_op_test.cc +++ b/tensorflow/core/kernels/merge_v2_checkpoints_op_test.cc @@ -115,7 +115,7 @@ class MergeV2CheckpointsOpTest : public OpsTestBase { for (int i = 0; i < 2; ++i) { int directory_found = Env::Default() - ->IsDirectory(io::Dirname(prefixes[i]).ToString()) + ->IsDirectory(std::string(io::Dirname(prefixes[i]))) .code(); if (delete_old_dirs) { EXPECT_EQ(error::NOT_FOUND, directory_found); diff --git a/tensorflow/core/kernels/remote_fused_graph_execute_utils.cc b/tensorflow/core/kernels/remote_fused_graph_execute_utils.cc index cc4d9a49a0..194a711d98 100644 --- a/tensorflow/core/kernels/remote_fused_graph_execute_utils.cc +++ b/tensorflow/core/kernels/remote_fused_graph_execute_utils.cc @@ -47,7 +47,7 @@ std::unordered_set BuildNodeSetFromNodeNamesAndPorts( std::unordered_set retval; for (const string& node_name_and_port : node_names_and_ports) { const TensorId tid = ParseTensorName(node_name_and_port); - retval.emplace(tid.first.ToString()); + retval.emplace(std::string(tid.first)); } return retval; } @@ -64,7 +64,7 @@ Node* FindMutableNodeByName(const string& name, Graph* graph) { const NodeDef* FindNodeDefByName(const string& input, const GraphDef& graph_def) { const TensorId tid = ParseTensorName(input); - const string name = tid.first.ToString(); + const string name = std::string(tid.first); for (const NodeDef& node_def : graph_def.node()) { if (node_def.name() == name) { return &node_def; @@ -77,7 +77,7 @@ bool IsSameNodeName(const NodeDef& node_def, const string& node_name_and_port, TensorId* tid) { CHECK_NOTNULL(tid); *tid = ParseTensorName(node_name_and_port); - if (node_def.name() == tid->first.ToString()) { + if (node_def.name() == tid->first) { return true; } return false; @@ -326,7 +326,7 @@ RemoteFusedGraphExecuteUtils::GetExecutorBuildRegistry() { const string& node_name) { for (const std::pair& pair : input_tensor_vector) { const TensorId tid = ParseTensorName(pair.first); - if (node_name == tid.first.ToString()) { + if (node_name == tid.first) { return true; } } @@ -423,7 +423,7 @@ RemoteFusedGraphExecuteUtils::AddOutputTensorShapeTypeByTensorShapeMap( std::vector data_types; std::vector shapes; const TensorId tid = ParseTensorName(name_and_port); - const string node_name = tid.first.ToString(); + const string node_name = std::string(tid.first); const int port = tid.second; const NodeDef* node_def = FindNodeDefByName(node_name, graph_def); CHECK_NOTNULL(node_def); @@ -522,7 +522,7 @@ RemoteFusedGraphExecuteUtils::GetTensorShapeType( const TensorShapeMap& tensor_shape_map, const string& node_name) { if (node_name.find(':') != string::npos) { const TensorId tid = ParseTensorName(node_name); - return GetTensorShapeType(tensor_shape_map, tid.first.ToString(), + return GetTensorShapeType(tensor_shape_map, std::string(tid.first), tid.second); } else { return GetTensorShapeType(tensor_shape_map, node_name, 0); @@ -570,7 +570,7 @@ RemoteFusedGraphExecuteUtils::BuildRemoteGraphInputsAndOutputsFromProto( const TensorId tid = ParseTensorName(name); CHECK_EQ(tensor_shape_map->count(name), 0); tensor_shape_map->emplace( - tid.first.ToString(), + std::string(tid.first), std::make_pair(tid.second, std::make_pair(tensor.dtype(), tensor.shape()))); } @@ -692,7 +692,7 @@ RemoteFusedGraphExecuteUtils::BuildRemoteFusedGraphExecuteOpNode( std::vector node_out_list; for (const string& input : inputs) { const TensorId tid = ParseTensorName(input); - Node* node = FindMutableNodeByName(tid.first.ToString(), graph); + Node* node = FindMutableNodeByName(std::string(tid.first), graph); CHECK_NOTNULL(node); node_out_list.emplace_back(node, tid.second); } @@ -848,7 +848,7 @@ RemoteFusedGraphExecuteUtils::BuildRemoteFusedGraphExecuteOpNode( for (const string& subgraph_input : std::get<1>(cluster)) { const TensorId tid = ParseTensorName(subgraph_input); - const string subgraph_input_name = tid.first.ToString(); + const string subgraph_input_name = std::string(tid.first); const int subgraph_input_port = tid.second; const NodeDef* node_def = FindNodeDefByName(subgraph_input_name, graph_def); CHECK_NOTNULL(node_def); @@ -895,7 +895,7 @@ RemoteFusedGraphExecuteUtils::BuildRemoteFusedGraphExecuteOpNode( std::deque queue; for (const string& output : border_outputs) { const TensorId tid = ParseTensorName(output); - const string& output_node_name = tid.first.ToString(); + const string& output_node_name = std::string(tid.first); for (const Node* node : graph.nodes()) { if (output_node_name == node->name()) { queue.push_back(node); @@ -916,8 +916,7 @@ RemoteFusedGraphExecuteUtils::BuildRemoteFusedGraphExecuteOpNode( bool input_found = false; for (const string& input : border_inputs) { const TensorId tid = ParseTensorName(input); - if (tid.first.ToString() == src_node->name() && - tid.second == src_port) { + if (tid.first == src_node->name() && tid.second == src_port) { input_found = true; border_input_nodes.insert(src_node); } @@ -976,7 +975,7 @@ RemoteFusedGraphExecuteUtils::BuildRemoteFusedGraphExecuteOpNode( for (int j = 0; j < border_outputs.size(); ++j) { const string& output = border_outputs.at(j); const TensorId tid = ParseTensorName(output); - const string output_name = tid.first.ToString(); + const string output_name = std::string(tid.first); Node* src_node = edge->src(); if (src_node != nullptr && src_node->name() == output_name && edge->src_output() == tid.second) { @@ -996,11 +995,12 @@ RemoteFusedGraphExecuteUtils::BuildRemoteFusedGraphExecuteOpNode( // RemoteFusedGraphExecuteOpNode for (const string& output : outputs) { const TensorId output_tid = ParseTensorName(output); - const string output_name = output_tid.first.ToString(); + const string output_name = std::string(output_tid.first); for (size_t i = 0; i < border_outputs.size(); ++i) { const TensorId subgraph_output_tid = ParseTensorName(border_outputs.at(i)); - const string& subgraph_output_name = subgraph_output_tid.first.ToString(); + const string& subgraph_output_name = + std::string(subgraph_output_tid.first); if (output_name == subgraph_output_name) { LOG(INFO) << "As graph output and subgraph output are same, " << "the graph output node is replaced by identity node"; @@ -1435,7 +1435,7 @@ RemoteFusedGraphExecuteUtils::BuildNodeMapFromOpsDefinitions( GraphDef* graph_def) { const TensorId tid = ParseTensorName(input); CHECK_EQ(0, tid.second); - const string node_name = tid.first.ToString(); + const string node_name = std::string(tid.first); for (NodeDef& node : *graph_def->mutable_node()) { if (node.name() != node_name) { continue; diff --git a/tensorflow/core/kernels/save_restore_v2_ops.cc b/tensorflow/core/kernels/save_restore_v2_ops.cc index 3acf290ea2..ab4de6c815 100644 --- a/tensorflow/core/kernels/save_restore_v2_ops.cc +++ b/tensorflow/core/kernels/save_restore_v2_ops.cc @@ -220,9 +220,9 @@ class MergeV2Checkpoints : public OpKernel { context, tensorflow::MergeBundles(env, input_prefixes, merged_prefix)); if (delete_old_dirs_) { - const string& merged_dir = io::Dirname(merged_prefix).ToString(); + const string& merged_dir = std::string(io::Dirname(merged_prefix)); for (const string& input_prefix : input_prefixes) { - const string& dirname = io::Dirname(input_prefix).ToString(); + const string& dirname = std::string(io::Dirname(input_prefix)); if (dirname == merged_dir) continue; Status status = env->DeleteDir(dirname); // For sharded save, only the first delete will go through and all diff --git a/tensorflow/core/kernels/string_strip_op.cc b/tensorflow/core/kernels/string_strip_op.cc index ae700f4294..2aeafa28c4 100644 --- a/tensorflow/core/kernels/string_strip_op.cc +++ b/tensorflow/core/kernels/string_strip_op.cc @@ -43,7 +43,7 @@ class StringStripOp : public OpKernel { for (int64 i = 0; i < input.size(); ++i) { StringPiece entry(input(i)); str_util::RemoveWhitespaceContext(&entry); - output(i) = entry.ToString(); + output(i) = std::string(entry); } } }; diff --git a/tensorflow/core/kernels/tensor_array_ops.cc b/tensorflow/core/kernels/tensor_array_ops.cc index 7ec26d95e6..ef9748b1aa 100644 --- a/tensorflow/core/kernels/tensor_array_ops.cc +++ b/tensorflow/core/kernels/tensor_array_ops.cc @@ -293,7 +293,7 @@ class TensorArrayGradOp : public TensorArrayCreationOp { resource.name()); } tensor_array_name = - StringPiece(resource.name()).substr(container.size()).ToString(); + std::string(StringPiece(resource.name()).substr(container.size())); } auto output_handle = tensor_array_output_handle->flat(); diff --git a/tensorflow/core/kernels/whole_file_read_ops.cc b/tensorflow/core/kernels/whole_file_read_ops.cc index 17a39ce29b..ed2bf3e8e2 100644 --- a/tensorflow/core/kernels/whole_file_read_ops.cc +++ b/tensorflow/core/kernels/whole_file_read_ops.cc @@ -134,7 +134,7 @@ class WriteFileOp : public OpKernel { "Contents tensor must be scalar, but had shape: ", contents_input->shape().DebugString())); const string& filename = filename_input->scalar()(); - const string dir = io::Dirname(filename).ToString(); + const string dir = std::string(io::Dirname(filename)); if (!context->env()->FileExists(dir).ok()) { OP_REQUIRES_OK(context, context->env()->RecursivelyCreateDir(dir)); } diff --git a/tensorflow/core/lib/strings/numbers.h b/tensorflow/core/lib/strings/numbers.h index e9add42849..9cb56415cb 100644 --- a/tensorflow/core/lib/strings/numbers.h +++ b/tensorflow/core/lib/strings/numbers.h @@ -140,11 +140,11 @@ inline bool ProtoParseNumeric(StringPiece s, uint64* value) { } inline bool ProtoParseNumeric(StringPiece s, float* value) { - return safe_strtof(s.ToString().c_str(), value); + return safe_strtof(std::string(s).c_str(), value); } inline bool ProtoParseNumeric(StringPiece s, double* value) { - return safe_strtod(s.ToString().c_str(), value); + return safe_strtod(std::string(s).c_str(), value); } // Convert strings to number of type T. diff --git a/tensorflow/core/lib/strings/scanner_test.cc b/tensorflow/core/lib/strings/scanner_test.cc index 55ff3405c3..b0f568a03e 100644 --- a/tensorflow/core/lib/strings/scanner_test.cc +++ b/tensorflow/core/lib/strings/scanner_test.cc @@ -42,24 +42,24 @@ TEST_F(ScannerTest, Any) { .Any(Scanner::DIGIT) .Any(Scanner::LETTER) .GetResult(&remaining, &match)); - EXPECT_EQ(" horse", match.ToString()); - EXPECT_EQ("0123", remaining.ToString()); + EXPECT_EQ(" horse", match); + EXPECT_EQ("0123", remaining); EXPECT_TRUE(Scanner("") .Any(Scanner::SPACE) .Any(Scanner::DIGIT) .Any(Scanner::LETTER) .GetResult(&remaining, &match)); - EXPECT_EQ("", remaining.ToString()); - EXPECT_EQ("", match.ToString()); + EXPECT_EQ("", remaining); + EXPECT_EQ("", match); EXPECT_TRUE(Scanner("----") .Any(Scanner::SPACE) .Any(Scanner::DIGIT) .Any(Scanner::LETTER) .GetResult(&remaining, &match)); - EXPECT_EQ("----", remaining.ToString()); - EXPECT_EQ("", match.ToString()); + EXPECT_EQ("----", remaining); + EXPECT_EQ("", match); } TEST_F(ScannerTest, AnySpace) { @@ -69,8 +69,8 @@ TEST_F(ScannerTest, AnySpace) { .One(Scanner::LETTER) .AnySpace() .GetResult(&remaining, &match)); - EXPECT_EQ(" a ", match.ToString()); - EXPECT_EQ("b ", remaining.ToString()); + EXPECT_EQ(" a ", match); + EXPECT_EQ("b ", remaining); } TEST_F(ScannerTest, AnyEscapedNewline) { @@ -143,8 +143,8 @@ TEST_F(ScannerTest, ScanUntil) { .ScanUntil('\'') .OneLiteral("'") .GetResult(&remaining, &match)); - EXPECT_EQ(R"( \\'rest)", remaining.ToString()); - EXPECT_EQ(R"(' \1 \2 \3 \')", match.ToString()); + EXPECT_EQ(R"( \\'rest)", remaining); + EXPECT_EQ(R"(' \1 \2 \3 \')", match); // The "scan until" character is not present. remaining = match = "unset"; @@ -152,15 +152,15 @@ TEST_F(ScannerTest, ScanUntil) { .OneLiteral("'") .ScanUntil('\'') .GetResult(&remaining, &match)); - EXPECT_EQ("unset", remaining.ToString()); - EXPECT_EQ("unset", match.ToString()); + EXPECT_EQ("unset", remaining); + EXPECT_EQ("unset", match); // Scan until an escape character. remaining = match = ""; EXPECT_TRUE( Scanner(R"(123\456)").ScanUntil('\\').GetResult(&remaining, &match)); - EXPECT_EQ(R"(\456)", remaining.ToString()); - EXPECT_EQ("123", match.ToString()); + EXPECT_EQ(R"(\456)", remaining); + EXPECT_EQ("123", match); } TEST_F(ScannerTest, ScanEscapedUntil) { @@ -170,8 +170,8 @@ TEST_F(ScannerTest, ScanEscapedUntil) { .ScanEscapedUntil('\'') .OneLiteral("'") .GetResult(&remaining, &match)); - EXPECT_EQ("rest", remaining.ToString()); - EXPECT_EQ(R"(' \1 \2 \3 \' \\')", match.ToString()); + EXPECT_EQ("rest", remaining); + EXPECT_EQ(R"(' \1 \2 \3 \' \\')", match); // The "scan until" character is not present. remaining = match = "unset"; @@ -179,27 +179,27 @@ TEST_F(ScannerTest, ScanEscapedUntil) { .OneLiteral("'") .ScanEscapedUntil('\'') .GetResult(&remaining, &match)); - EXPECT_EQ("unset", remaining.ToString()); - EXPECT_EQ("unset", match.ToString()); + EXPECT_EQ("unset", remaining); + EXPECT_EQ("unset", match); } TEST_F(ScannerTest, ZeroOrOneLiteral) { StringPiece remaining, match; EXPECT_TRUE( Scanner("abc").ZeroOrOneLiteral("abC").GetResult(&remaining, &match)); - EXPECT_EQ("abc", remaining.ToString()); - EXPECT_EQ("", match.ToString()); + EXPECT_EQ("abc", remaining); + EXPECT_EQ("", match); EXPECT_TRUE( Scanner("abcd").ZeroOrOneLiteral("ab").ZeroOrOneLiteral("c").GetResult( &remaining, &match)); - EXPECT_EQ("d", remaining.ToString()); - EXPECT_EQ("abc", match.ToString()); + EXPECT_EQ("d", remaining); + EXPECT_EQ("abc", match); EXPECT_TRUE( Scanner("").ZeroOrOneLiteral("abc").GetResult(&remaining, &match)); - EXPECT_EQ("", remaining.ToString()); - EXPECT_EQ("", match.ToString()); + EXPECT_EQ("", remaining); + EXPECT_EQ("", match); } // Test output of GetResult (including the forms with optional params), @@ -215,24 +215,24 @@ TEST_F(ScannerTest, CaptureAndGetResult) { .StopCapture() .Any(Scanner::SPACE) .GetResult(&remaining, &match)); - EXPECT_EQ("second", remaining.ToString()); - EXPECT_EQ("first", match.ToString()); + EXPECT_EQ("second", remaining); + EXPECT_EQ("first", match); EXPECT_TRUE(scan.GetResult()); remaining = ""; EXPECT_TRUE(scan.GetResult(&remaining)); - EXPECT_EQ("second", remaining.ToString()); + EXPECT_EQ("second", remaining); remaining = ""; match = ""; EXPECT_TRUE(scan.GetResult(&remaining, &match)); - EXPECT_EQ("second", remaining.ToString()); - EXPECT_EQ("first", match.ToString()); + EXPECT_EQ("second", remaining); + EXPECT_EQ("first", match); scan.RestartCapture().One(Scanner::LETTER).One(Scanner::LETTER); remaining = ""; match = ""; EXPECT_TRUE(scan.GetResult(&remaining, &match)); - EXPECT_EQ("cond", remaining.ToString()); - EXPECT_EQ("se", match.ToString()); + EXPECT_EQ("cond", remaining); + EXPECT_EQ("se", match); } // Tests that if StopCapture is not called, then calling GetResult, then @@ -242,14 +242,14 @@ TEST_F(ScannerTest, MultipleGetResultExtendsCapture) { Scanner scan("one2three"); EXPECT_TRUE(scan.Many(Scanner::LETTER).GetResult(&remaining, &match)); - EXPECT_EQ("2three", remaining.ToString()); - EXPECT_EQ("one", match.ToString()); + EXPECT_EQ("2three", remaining); + EXPECT_EQ("one", match); EXPECT_TRUE(scan.Many(Scanner::DIGIT).GetResult(&remaining, &match)); - EXPECT_EQ("three", remaining.ToString()); - EXPECT_EQ("one2", match.ToString()); + EXPECT_EQ("three", remaining); + EXPECT_EQ("one2", match); EXPECT_TRUE(scan.Many(Scanner::LETTER).GetResult(&remaining, &match)); - EXPECT_EQ("", remaining.ToString()); - EXPECT_EQ("one2three", match.ToString()); + EXPECT_EQ("", remaining); + EXPECT_EQ("one2three", match); } TEST_F(ScannerTest, FailedMatchDoesntChangeResult) { @@ -258,8 +258,8 @@ TEST_F(ScannerTest, FailedMatchDoesntChangeResult) { StringPiece remaining = "rem"; StringPiece match = "match"; EXPECT_FALSE(scan.One(Scanner::SPACE).GetResult(&remaining, &match)); - EXPECT_EQ("rem", remaining.ToString()); - EXPECT_EQ("match", match.ToString()); + EXPECT_EQ("rem", remaining); + EXPECT_EQ("match", match); } TEST_F(ScannerTest, DefaultCapturesAll) { @@ -271,8 +271,8 @@ TEST_F(ScannerTest, DefaultCapturesAll) { .AnySpace() .Any(Scanner::LETTER) .GetResult(&remaining, &match)); - EXPECT_EQ("", remaining.ToString()); - EXPECT_EQ("a b", match.ToString()); + EXPECT_EQ("", remaining); + EXPECT_EQ("a b", match); } TEST_F(ScannerTest, AllCharClasses) { diff --git a/tensorflow/core/lib/strings/str_util.cc b/tensorflow/core/lib/strings/str_util.cc index 4598b8ccc7..cab8f81585 100644 --- a/tensorflow/core/lib/strings/str_util.cc +++ b/tensorflow/core/lib/strings/str_util.cc @@ -332,7 +332,7 @@ string StringReplace(StringPiece s, StringPiece oldsub, StringPiece newsub, bool replace_all) { // TODO(jlebar): We could avoid having to shift data around in the string if // we had a StringPiece::find() overload that searched for a StringPiece. - string res = s.ToString(); + string res = std::string(s); size_t pos = 0; while ((pos = res.find(oldsub.data(), pos, oldsub.size())) != string::npos) { res.replace(pos, oldsub.size(), newsub.data(), newsub.size()); @@ -449,7 +449,7 @@ bool SplitAndParseAsFloats(StringPiece text, char delim, return SplitAndParseAsInts(text, delim, [](StringPiece str, float* value) { return strings::safe_strtof( - str.ToString().c_str(), value); + std::string(str).c_str(), value); }, result); } diff --git a/tensorflow/core/lib/strings/str_util.h b/tensorflow/core/lib/strings/str_util.h index e97d00b975..c887db7eff 100644 --- a/tensorflow/core/lib/strings/str_util.h +++ b/tensorflow/core/lib/strings/str_util.h @@ -205,7 +205,7 @@ std::vector Split(StringPiece text, StringPiece delims, Predicate p) { if ((i == text.size()) || (delims.find(text[i]) != StringPiece::npos)) { StringPiece token(text.data() + token_start, i - token_start); if (p(token)) { - result.push_back(token.ToString()); + result.push_back(std::string(token)); } token_start = i + 1; } diff --git a/tensorflow/core/platform/env.cc b/tensorflow/core/platform/env.cc index b9a9ef85eb..fe7d0aa7d1 100644 --- a/tensorflow/core/platform/env.cc +++ b/tensorflow/core/platform/env.cc @@ -92,7 +92,7 @@ Env::Env() : file_system_registry_(new FileSystemRegistryImpl) {} Status Env::GetFileSystemForFile(const string& fname, FileSystem** result) { StringPiece scheme, host, path; io::ParseURI(fname, &scheme, &host, &path); - FileSystem* file_system = file_system_registry_->Lookup(scheme.ToString()); + FileSystem* file_system = file_system_registry_->Lookup(std::string(scheme)); if (!file_system) { if (scheme.empty()) { scheme = "[local]"; @@ -166,7 +166,7 @@ bool Env::FilesExist(const std::vector& files, for (const auto& file : files) { StringPiece scheme, host, path; io::ParseURI(file, &scheme, &host, &path); - files_per_fs[scheme.ToString()].push_back(file); + files_per_fs[std::string(scheme)].push_back(file); } std::unordered_map per_file_status; diff --git a/tensorflow/core/platform/env_test.cc b/tensorflow/core/platform/env_test.cc index a70a417e6a..c461a40086 100644 --- a/tensorflow/core/platform/env_test.cc +++ b/tensorflow/core/platform/env_test.cc @@ -357,7 +357,7 @@ TEST_F(DefaultEnvTest, LocalTempFilename) { CHECK_EQ(error::OUT_OF_RANGE, file_to_read->Read(0 /* offset */, 1024 /* n */, &content, scratch) .code()); - EXPECT_EQ("Null", content.ToString()); + EXPECT_EQ("Null", content); // Delete the temporary file. TF_CHECK_OK(env->DeleteFile(filename)); diff --git a/tensorflow/core/platform/file_system.cc b/tensorflow/core/platform/file_system.cc index b55e94d552..922773684b 100644 --- a/tensorflow/core/platform/file_system.cc +++ b/tensorflow/core/platform/file_system.cc @@ -158,7 +158,7 @@ Status FileSystem::RecursivelyCreateDir(const string& dirname) { std::reverse(sub_dirs.begin(), sub_dirs.end()); // Now create the directories. - string built_path = remaining_dir.ToString(); + string built_path = std::string(remaining_dir); for (const StringPiece sub_dir : sub_dirs) { built_path = io::JoinPath(built_path, sub_dir); Status status = CreateDir(io::CreateURI(scheme, host, built_path)); diff --git a/tensorflow/core/platform/file_system_helper.cc b/tensorflow/core/platform/file_system_helper.cc index 22c5057281..0ba0e6304f 100644 --- a/tensorflow/core/platform/file_system_helper.cc +++ b/tensorflow/core/platform/file_system_helper.cc @@ -59,7 +59,7 @@ Status GetMatchingPaths(FileSystem* fs, Env* env, const string& pattern, string fixed_prefix = pattern.substr(0, pattern.find_first_of("*?[\\")); string eval_pattern = pattern; std::vector all_files; - string dir = io::Dirname(fixed_prefix).ToString(); + string dir = std::string(io::Dirname(fixed_prefix)); // If dir is empty then we need to fix up fixed_prefix and eval_pattern to // include . as the top level directory. if (dir.empty()) { diff --git a/tensorflow/core/platform/file_system_test.cc b/tensorflow/core/platform/file_system_test.cc index f261b8f576..c0a16c95f9 100644 --- a/tensorflow/core/platform/file_system_test.cc +++ b/tensorflow/core/platform/file_system_test.cc @@ -125,7 +125,7 @@ class InterPlanetaryFileSystem : public NullFileSystem { ASSERT_EQ(scheme, "ipfs"); ASSERT_EQ(host, "solarsystem"); str_util::ConsumePrefix(&path, "/"); - *parsed_path = path.ToString(); + *parsed_path = std::string(path); } std::map> celestial_bodies_ = { diff --git a/tensorflow/core/util/command_line_flags.cc b/tensorflow/core/util/command_line_flags.cc index 480ce94fca..8c27d01917 100644 --- a/tensorflow/core/util/command_line_flags.cc +++ b/tensorflow/core/util/command_line_flags.cc @@ -32,7 +32,7 @@ bool ParseStringFlag(tensorflow::StringPiece arg, tensorflow::StringPiece flag, if (str_util::ConsumePrefix(&arg, "--") && str_util::ConsumePrefix(&arg, flag) && str_util::ConsumePrefix(&arg, "=")) { - *value_parsing_ok = hook(arg.ToString()); + *value_parsing_ok = hook(std::string(arg)); return true; } diff --git a/tensorflow/core/util/env_var.cc b/tensorflow/core/util/env_var.cc index c844850179..8d43bcc927 100644 --- a/tensorflow/core/util/env_var.cc +++ b/tensorflow/core/util/env_var.cc @@ -28,7 +28,7 @@ namespace tensorflow { Status ReadBoolFromEnvVar(StringPiece env_var_name, bool default_val, bool* value) { *value = default_val; - const char* tf_env_var_val = getenv(env_var_name.ToString().c_str()); + const char* tf_env_var_val = getenv(std::string(env_var_name).c_str()); if (tf_env_var_val == nullptr) { return Status::OK(); } @@ -48,7 +48,7 @@ Status ReadBoolFromEnvVar(StringPiece env_var_name, bool default_val, Status ReadInt64FromEnvVar(StringPiece env_var_name, int64 default_val, int64* value) { *value = default_val; - const char* tf_env_var_val = getenv(env_var_name.ToString().c_str()); + const char* tf_env_var_val = getenv(std::string(env_var_name).c_str()); if (tf_env_var_val == nullptr) { return Status::OK(); } @@ -62,11 +62,11 @@ Status ReadInt64FromEnvVar(StringPiece env_var_name, int64 default_val, Status ReadStringFromEnvVar(StringPiece env_var_name, StringPiece default_val, string* value) { - const char* tf_env_var_val = getenv(env_var_name.ToString().c_str()); + const char* tf_env_var_val = getenv(std::string(env_var_name).c_str()); if (tf_env_var_val != nullptr) { *value = tf_env_var_val; } else { - *value = default_val.ToString(); + *value = std::string(default_val); } return Status::OK(); } diff --git a/tensorflow/core/util/example_proto_fast_parsing.cc b/tensorflow/core/util/example_proto_fast_parsing.cc index 7946fa1782..3ce7988057 100644 --- a/tensorflow/core/util/example_proto_fast_parsing.cc +++ b/tensorflow/core/util/example_proto_fast_parsing.cc @@ -353,7 +353,7 @@ bool TestFastParse(const string& serialized, Example* example) { // I.e. last entry in the map overwrites all the previous ones. parsed::FeatureMapEntry& name_and_feature = parsed_example[parsed_example_size - i - 1]; - string name = name_and_feature.first.ToString(); + string name = std::string(name_and_feature.first); if ((*features.mutable_feature()).count(name) > 0) continue; auto& value = (*features.mutable_feature())[name]; -- cgit v1.2.3